R - Type of object that is read from this connection.W - Type of object that is written to this connection.public abstract class Connection<R,W> extends java.lang.Object implements ChannelOperations<W>
ChannelOption.AUTO_READ is set to true on the underneath channel, data will be read from the
connection if and only if there is a subscription to the input stream returned by getInput().
In case, the input data is not required to be consumed, one should call ignoreInput(), otherwise, data will
never be read from the channel.| Modifier and Type | Field and Description |
|---|---|
static io.netty.util.AttributeKey<Connection> |
CONNECTION_ATTRIBUTE_KEY |
protected MarkAwarePipeline |
markAwarePipeline |
FLUSH_ON_EACH_BYTES, FLUSH_ON_EACH_FILE_REGION, FLUSH_ON_EACH_STRING, FLUSH_ONLY_ON_READ_COMPLETE| Modifier | Constructor and Description |
|---|---|
protected |
Connection(io.netty.channel.Channel nettyChannel) |
protected |
Connection(Connection<?,?> toCopy,
ContentSource<R> contentSource) |
protected |
Connection(Connection<R,W> toCopy) |
| Modifier and Type | Method and Description |
|---|---|
abstract <RR,WW> Connection<RR,WW> |
addChannelHandlerAfter(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String baseName,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
abstract <RR,WW> Connection<RR,WW> |
addChannelHandlerAfter(java.lang.String baseName,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
abstract <RR,WW> Connection<RR,WW> |
addChannelHandlerBefore(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String baseName,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
abstract <RR,WW> Connection<RR,WW> |
addChannelHandlerBefore(java.lang.String baseName,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
abstract <RR,WW> Connection<RR,WW> |
addChannelHandlerFirst(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
abstract <RR,WW> Connection<RR,WW> |
addChannelHandlerFirst(java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
abstract <RR,WW> Connection<RR,WW> |
addChannelHandlerLast(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
abstract <RR,WW> Connection<RR,WW> |
addChannelHandlerLast(java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
protected void |
connectCloseToChannelClose() |
io.netty.channel.ChannelPipeline |
getChannelPipeline()
Returns the
ChannelPipeline for this connection. |
ContentSource<R> |
getInput()
Returns a stream of data that is read from the connection.
|
MarkAwarePipeline |
getResettableChannelPipeline()
Returns the
MarkAwarePipeline for this connection, changes to which can be reverted at any point in time. |
rx.Observable<java.lang.Void> |
ignoreInput()
Ignores all input on this connection.
|
abstract <RR,WW> Connection<RR,WW> |
pipelineConfigurator(rx.functions.Action1<io.netty.channel.ChannelPipeline> pipelineConfigurator)
Configures the
ChannelPipeline for this channel, using the passed pipelineConfigurator. |
abstract <RR> Connection<RR,W> |
transformRead(rx.Observable.Transformer<R,RR> transformer)
Transforms this connection's input stream using the passed
transformer to create a new
Connection instance. |
abstract <WW> Connection<R,WW> |
transformWrite(AllocatingTransformer<WW,W> transformer)
Transforms this connection to enable writing a different object type.
|
io.netty.channel.Channel |
unsafeNettyChannel()
Returns the underlying netty
Channel for this connection. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, close, closeListener, closeNow, flush, write, write, writeAndFlushOnEach, writeBytes, writeBytes, writeBytesAndFlushOnEach, writeFileRegion, writeFileRegion, writeFileRegionAndFlushOnEach, writeString, writeString, writeStringAndFlushOnEachpublic static final io.netty.util.AttributeKey<Connection> CONNECTION_ATTRIBUTE_KEY
protected final MarkAwarePipeline markAwarePipeline
protected Connection(io.netty.channel.Channel nettyChannel)
protected Connection(Connection<R,W> toCopy)
protected Connection(Connection<?,?> toCopy, ContentSource<R> contentSource)
public ContentSource<R> getInput()
ChannelOption.AUTO_READ is set to true, the content will only be read from the
underneath channel, if there is a subscriber to the input.
In case, input is not required to be read, call ignoreInput()public rx.Observable<java.lang.Void> ignoreInput()
ChannelOption.AUTO_READ is set to true, the content will only be read from the
underneath channel, if there is a subscriber to the input. So, upon recieving this connection, either one should
call this method or eventually subscribe to the stream returned by getInput()Observable, subscription to which will discard the input. This Observable will
error/complete when the input errors/completes and unsubscription from here will unsubscribe from the content.public abstract <RR,WW> Connection<RR,WW> addChannelHandlerFirst(java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler to ChannelPipeline for this connection. The specified handler is added at
the first position of the pipeline as specified by ChannelPipeline.addFirst(String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.name - Name of the handler.handler - Handler instance to add.this.public abstract <RR,WW> Connection<RR,WW> addChannelHandlerFirst(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler to ChannelPipeline for this connection. The specified handler is added at
the first position of the pipeline as specified by
ChannelPipeline.addFirst(EventExecutorGroup, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.group - the EventExecutorGroup which will be used to execute the ChannelHandler methodsname - the name of the handler to appendhandler - Handler instance to add.this.public abstract <RR,WW> Connection<RR,WW> addChannelHandlerLast(java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler to ChannelPipeline for this connection. The specified handler is added at
the last position of the pipeline as specified by ChannelPipeline.addLast(String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.name - Name of the handler.handler - Handler instance to add.this.public abstract <RR,WW> Connection<RR,WW> addChannelHandlerLast(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler to ChannelPipeline for this connection. The specified handler is added at
the last position of the pipeline as specified by
ChannelPipeline.addLast(EventExecutorGroup, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.group - the EventExecutorGroup which will be used to execute the ChannelHandler methodsname - the name of the handler to appendhandler - Handler instance to add.this.public abstract <RR,WW> Connection<RR,WW> addChannelHandlerBefore(java.lang.String baseName, java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler to ChannelPipeline for this connection. The specified
handler is added before an existing handler with the passed baseName in the pipeline as specified by
ChannelPipeline.addBefore(String, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.baseName - the name of the existing handlername - Name of the handler.handler - Handler instance to add.this.public abstract <RR,WW> Connection<RR,WW> addChannelHandlerBefore(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String baseName, java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler to ChannelPipeline for this connection. The specified
handler is added before an existing handler with the passed baseName in the pipeline as specified by
ChannelPipeline.addBefore(EventExecutorGroup, String, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.group - the EventExecutorGroup which will be used to execute the ChannelHandler
methodsbaseName - the name of the existing handlername - the name of the handler to appendhandler - Handler instance to add.this.public abstract <RR,WW> Connection<RR,WW> addChannelHandlerAfter(java.lang.String baseName, java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler to ChannelPipeline for this connection. The specified
handler is added after an existing handler with the passed baseName in the pipeline as specified by
ChannelPipeline.addAfter(String, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.baseName - the name of the existing handlername - Name of the handler.handler - Handler instance to add.this.public abstract <RR,WW> Connection<RR,WW> addChannelHandlerAfter(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String baseName, java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler to ChannelPipeline for this connection. The specified
handler is added after an existing handler with the passed baseName in the pipeline as specified by
ChannelPipeline.addAfter(EventExecutorGroup, String, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.group - the EventExecutorGroup which will be used to execute the ChannelHandler methodsbaseName - the name of the existing handlername - the name of the handler to appendhandler - Handler instance to add.this.public abstract <RR,WW> Connection<RR,WW> pipelineConfigurator(rx.functions.Action1<io.netty.channel.ChannelPipeline> pipelineConfigurator)
ChannelPipeline for this channel, using the passed pipelineConfigurator.pipelineConfigurator - Action to configure ChannelPipeline.this.public abstract <RR> Connection<RR,W> transformRead(rx.Observable.Transformer<R,RR> transformer)
transformer to create a new
Connection instance.RR - New type of the input stream.transformer - Transformer to transform the input stream.public abstract <WW> Connection<R,WW> transformWrite(AllocatingTransformer<WW,W> transformer)
transformWrite in interface ChannelOperations<W>WW - New object types to be written to the connection.transformer - Transformer to transform objects written to the channel.public MarkAwarePipeline getResettableChannelPipeline()
MarkAwarePipeline for this connection, changes to which can be reverted at any point in time.public io.netty.channel.ChannelPipeline getChannelPipeline()
ChannelPipeline for this connection.ChannelPipeline for this connection.public io.netty.channel.Channel unsafeNettyChannel()
Channel for this connection.
Channel for this connection.protected void connectCloseToChannelClose()