diff --git a/4.0/guide/index.html b/4.0/guide/index.html index 5d823833517..6835c4b5717 100644 --- a/4.0/guide/index.html +++ b/4.0/guide/index.html @@ -261,7 +261,7 @@
ChannelInboundByteHandlerAdapter {
4
@Override
- 6 public void inboundBufferUpdate(ChannelHandlerContext ctx, ByteBuf in) {
+ 6 public void inboundBufferUpdate(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
in.clear();
8 }
@@ -281,13 +281,7 @@
- DiscardServerHandler extends
- , which is an implementation of
- . provides various event
- handler methods that you can override. For now, it is just enough
- to extend ChannelInboundByteHandlerAdapter rather than to implement
- the handler interfaces by yourself.
-
+ DiscardServerHandler extends ChannelInboundByteHandlerAdapter, which is an implementation of ChannelStateHandler. ChannelStateHandler provides various event handler methods that you can override. For now, it is just enough to extend ChannelInboundByteHandlerAdapter rather than to implement the handler interfaces by yourself.
ServerBootstrap bootstrap =
- 10 new
();
+ 10 new ServerBootstrap
();
try {
- 12 bootstrap.group(new NioEventLoopGroup(), new NioEventLoopGroup
();
- .channel(
)
+ 12 bootstrap.group(new NioEventLoopGroup(), new NioEventLoopGroup
())
+ .channel(NioServerSocketChannel.class
)
14 .childHandler(new ChannelInitializer<SocketChannel>() {
@Override
16 public void initChannel(SocketChannel channel) throws Exception {
channel.pipeline().addLast(new DiscardServerHandler());
18 }
})
- 20 .setChildOption(.TCP_NO_DELAY, true)
- .setChildOption(.KEEP_ALIVE, true)
+ 20 .childOption(ChannelOption.TCP_NODELAY, true)
+ .childOption(ChannelOption.SO_KEEPALIVE, true);
22
ChannelFuture future = bootstrap.bind(new InetSocketAddress(8080)).sync();
24
future.channel().closeFuture().sync();
26 } finally {
- b.shutdown();
+ bootstrap.shutdown();
28 }
}
30 }
@@ -501,8 +495,8 @@ 1 @Override - 2 public void inboundBufferUpdated(ChannelHandlerContextctx,ByteBufin) { - while(in.readable()) { + 2 public void inboundBufferUpdated(ChannelHandlerContextctx,ByteBufin) throws Exception { + while(in.isReadable()) { 4 System.out.println((char) buf.readByte()); System.out.flush(); 6 } @@ -605,7 +599,7 @@5. Writing a Time Server
1 package io.netty.example.time; 2 - public class TimeServerHandler extends { + public class TimeServerHandler extendsChannelInboundByteHandlerAdapter{ 4 @Override 6 public void channelActive(ChannelHandlerContextctx) {4. How do I pass data between handlers in the same Channel?