public class SimpleChannelUpstreamHandler extends java.lang.Object implements ChannelUpstreamHandler
ChannelUpstreamHandler
which provides an individual handler method
for each event type. This handler down-casts the received upstream event
into more meaningful sub-type event and calls an appropriate handler method
with the down-cast event. The names of the methods are identical to the
upstream event names, as introduced in the ChannelEvent
documentation.
Please use SimpleChannelHandler
if you need to implement both
ChannelUpstreamHandler
and ChannelDownstreamHandler
.
handleUpstream
method
You can override the handleUpstream
method just like overriding an ordinary Java method. Please make sure to
call super.handleUpstream()
so that other handler methods are invoked
properly:
public class MyChannelHandler extendsSimpleChannelUpstreamHandler
{@Override
public void handleUpstream(ChannelHandlerContext
ctx,ChannelEvent
e) throws Exception { // Log all channel state changes. if (e instanceofChannelStateEvent
) { logger.info("Channel state changed: " + e); } super.handleUpstream(ctx, e); } }
ChannelHandler.Sharable
构造器和说明 |
---|
SimpleChannelUpstreamHandler() |
限定符和类型 | 方法和说明 |
---|---|
void |
channelBound(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when a
Channel is open and bound to a local address,
but not connected. |
void |
channelClosed(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when a
Channel was closed and all its related resources
were released. |
void |
channelConnected(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when a
Channel is open, bound to a local address, and
connected to a remote address. |
void |
channelDisconnected(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when a
Channel was disconnected from its remote peer. |
void |
channelInterestChanged(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when a
Channel 's interestOps
was changed. |
void |
channelOpen(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when a
Channel is open, but not bound nor connected. |
void |
channelUnbound(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when a
Channel was unbound from the current local address. |
void |
childChannelClosed(ChannelHandlerContext ctx,
ChildChannelStateEvent e)
Invoked when a child
Channel was closed. |
void |
childChannelOpen(ChannelHandlerContext ctx,
ChildChannelStateEvent e)
Invoked when a child
Channel was open. |
void |
exceptionCaught(ChannelHandlerContext ctx,
ExceptionEvent e)
Invoked when an exception was raised by an I/O thread or a
ChannelHandler . |
void |
handleUpstream(ChannelHandlerContext ctx,
ChannelEvent e)
Handles the specified upstream event.
|
void |
messageReceived(ChannelHandlerContext ctx,
MessageEvent e)
Invoked when a message object (e.g:
ChannelBuffer ) was received
from a remote peer. |
void |
writeComplete(ChannelHandlerContext ctx,
WriteCompletionEvent e)
Invoked when something was written into a
Channel . |
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws java.lang.Exception
handleUpstream
在接口中 ChannelUpstreamHandler
ctx
- the context object for this handlere
- the upstream event to process or interceptjava.lang.Exception
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws java.lang.Exception
ChannelBuffer
) was received
from a remote peer.java.lang.Exception
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws java.lang.Exception
ChannelHandler
.java.lang.Exception
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel
is open, but not bound nor connected.
java.lang.Exception
public void channelBound(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel
is open and bound to a local address,
but not connected.
java.lang.Exception
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel
is open, bound to a local address, and
connected to a remote address.
java.lang.Exception
public void channelInterestChanged(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel
's interestOps
was changed.java.lang.Exception
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel
was disconnected from its remote peer.java.lang.Exception
public void channelUnbound(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel
was unbound from the current local address.java.lang.Exception
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws java.lang.Exception
Channel
was closed and all its related resources
were released.java.lang.Exception
public void writeComplete(ChannelHandlerContext ctx, WriteCompletionEvent e) throws java.lang.Exception
Channel
.java.lang.Exception
public void childChannelOpen(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws java.lang.Exception
Channel
was open.
(e.g. a server channel accepted a connection)java.lang.Exception
public void childChannelClosed(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws java.lang.Exception
Channel
was closed.
(e.g. the accepted connection was closed)java.lang.Exception