* Better documentation for developers

* Fixed a bug where a channelOpen event is swallowed
This commit is contained in:
Trustin Lee 2009-12-17 10:19:09 +00:00
parent 3fcfc910e1
commit 65634bda11
2 changed files with 13 additions and 2 deletions

View File

@ -202,7 +202,9 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
if (ctx.getPipeline().isAttached()) {
// channelOpen() has been called already - initialize here instead.
// channelOpen event has been fired already, which means
// this.channelOpen() will not be invoked.
// We have to initialize here instead.
initialize(ctx);
}
}
@ -222,7 +224,11 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
// This method will be invoked only if this handler was added
// before channelOpen event is fired. If a user adds this handler
// after the channelOpen event, initialize() will be called by beforeAdd().
initialize(ctx);
ctx.sendUpstream(e);
}
@Override

View File

@ -121,7 +121,9 @@ public class ReadTimeoutHandler extends SimpleChannelUpstreamHandler
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
if (ctx.getPipeline().isAttached()) {
// channelOpen() has been called already - initialize here instead.
// channelOpen event has been fired already, which means
// this.channelOpen() will not be invoked.
// We have to initialize here instead.
initialize(ctx);
}
}
@ -141,6 +143,9 @@ public class ReadTimeoutHandler extends SimpleChannelUpstreamHandler
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
// This method will be invoked only if this handler was added
// before channelOpen event is fired. If a user adds this handler
// after the channelOpen event, initialize() will be called by beforeAdd().
initialize(ctx);
ctx.sendUpstream(e);
}