ChannelHandler to interact with its ChannelPipeline
and other handlers. Among other things a handler can notify the next ChannelHandler in the
ChannelPipeline as well as modify the ChannelPipeline it belongs to dynamically.
ChannelPipeline by calling one of the various methods
provided here.
Please refer to ChannelPipeline to understand how an event flows.
ChannelPipeline your handler belongs to by calling
pipeline(). A non-trivial application could insert, remove, or
replace handlers in the pipeline dynamically at runtime.
ChannelHandlerContext for later use, such as
triggering an event outside the handler methods, even from a different thread.
public class MyHandler extendsChannelDuplexHandler{ privateChannelHandlerContextctx; public void beforeAdd(ChannelHandlerContextctx) { this.ctx = ctx; } public void login(String username, password) { ctx.write(new LoginMessage(username, password)); } ... }
attr(AttributeKey) allow you to
store and access stateful information that is related with a ChannelHandler / Channel and its
context. Please refer to ChannelHandler to learn various recommended
ways to manage stateful information.
ChannelHandlerContextChannelHandler instance can be added to more than
one ChannelPipeline. It means a single ChannelHandler
instance can have more than one ChannelHandlerContext and therefore
the single instance can be invoked with different
ChannelHandlerContexts if it is added to one or more ChannelPipelines more than once.
Also note that a ChannelHandler that is supposed to be added to multiple ChannelPipelines should
be marked as io.netty.channel.ChannelHandler.Sharable .
Please refer to the ChannelHandler, and
ChannelPipeline to find out more about inbound and outbound operations,
what fundamental differences they have, how they flow in a pipeline, and how to handle
the operation in your application.
| alloc | back to summary |
|---|---|
| public ByteBufAllocator alloc() Return the assigned | |
| attr | back to summary |
|---|---|
| public <T> Attribute Redeclares io. Doc from io. Deprecated Get the
| |
| channel | back to summary |
|---|---|
| public Channel channel() Return the | |
| executor | back to summary |
|---|---|
| public EventExecutor executor() Returns the | |
| fireChannelActive | back to summary |
|---|---|
| public ChannelHandlerContext fireChannelActive() Redeclares io. Doc from io. A
| |
| fireChannelInactive | back to summary |
|---|---|
| public ChannelHandlerContext fireChannelInactive() Redeclares io. Doc from io. A
| |
| fireChannelRead | back to summary |
|---|---|
| public ChannelHandlerContext fireChannelRead(Object msg) Redeclares io. Doc from io. A
| |
| fireChannelReadComplete | back to summary |
|---|---|
| public ChannelHandlerContext fireChannelReadComplete() Redeclares io. Doc from io. Triggers an
| |
| fireChannelRegistered | back to summary |
|---|---|
| public ChannelHandlerContext fireChannelRegistered() Redeclares io. Doc from io. A
| |
| fireChannelUnregistered | back to summary |
|---|---|
| public ChannelHandlerContext fireChannelUnregistered() Redeclares io. Doc from io. A
| |
| fireChannelWritabilityChanged | back to summary |
|---|---|
| public ChannelHandlerContext fireChannelWritabilityChanged() Redeclares io. Doc from io. Triggers an
| |
| fireExceptionCaught | back to summary |
|---|---|
| public ChannelHandlerContext fireExceptionCaught(Throwable cause) Redeclares io. Doc from io. A
| |
| fireUserEventTriggered | back to summary |
|---|---|
| public ChannelHandlerContext fireUserEventTriggered(Object evt) Redeclares io. Doc from io. A
| |
| flush | back to summary |
|---|---|
| public ChannelHandlerContext flush() Redeclares io. Doc from io. Request to flush all pending messages via this ChannelOutboundInvoker.
| |
| handler | back to summary |
|---|---|
| public ChannelHandler handler() The | |
| hasAttr | back to summary |
|---|---|
| public <T> boolean hasAttr(AttributeKey<T> key) Redeclares io. Doc from io. Deprecated Returns
| |
| isRemoved | back to summary |
|---|---|
| public boolean isRemoved() Return | |
| name | back to summary |
|---|---|
| public String name() The unique name of the | |
| pipeline | back to summary |
|---|---|
| public ChannelPipeline pipeline() Return the assigned | |
| read | back to summary |
|---|---|
| public ChannelHandlerContext read() Redeclares io. Doc from io. Request to Read data from the
This will result in having the
| |