From a39d3e89ffb743cfbec3a91df18de83c43d0a9df Mon Sep 17 00:00:00 2001 From: rafaelliu Date: Mon, 10 Jun 2013 17:23:46 -0300 Subject: [PATCH] Guide revision (Chapter 1, up until item 4) --- 4.0/guide/index.html | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) 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 @@

2. Writing a Discard Server

public class DiscardServerHandler extends ChannelInboundByteHandlerAdapter {1 4 @Override - 6 public void inboundBufferUpdate(ChannelHandlerContext ctx, ByteBuf in) {2 + 6 public void inboundBufferUpdate(ChannelHandlerContext ctx, ByteBuf in) throws Exception {2 in.clear(); 8 } @@ -281,13 +281,7 @@

2. Writing a Discard Server

- 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.

@@ -344,24 +338,24 @@

2. Writing a Discard Server

8 public static void main(String[] args) throws Exception { ServerBootstrap bootstrap = - 10 new 4(); + 10 new ServerBootstrap4(); try { - 12 bootstrap.group(new NioEventLoopGroup(), new NioEventLoopGroup5(); - .channel(6) + 12 bootstrap.group(new NioEventLoopGroup(), new NioEventLoopGroup5()) + .channel(NioServerSocketChannel.class6) 14 .childHandler(new ChannelInitializer<SocketChannel>() {7 @Override 16 public void initChannel(SocketChannel channel) throws Exception { channel.pipeline().addLast(new DiscardServerHandler()); 18 } }) - 20 .setChildOption(.TCP_NO_DELAY, true)8 - .setChildOption(.KEEP_ALIVE, true) + 20 .childOption(ChannelOption.TCP_NODELAY, true)8 + .childOption(ChannelOption.SO_KEEPALIVE, true); 22 ChannelFuture future = bootstrap.bind(new InetSocketAddress(8080)).sync();9 24 future.channel().closeFuture().sync(); 26 } finally { - b.shutdown(); + bootstrap.shutdown(); 28 } } 30 } @@ -501,8 +495,8 @@

3. Looking into the Received Data

  1 @Override
-  2 public void inboundBufferUpdated(ChannelHandlerContext ctx, ByteBuf in) {
-        while(in.readable()) {
+  2 public void inboundBufferUpdated(ChannelHandlerContext ctx, ByteBuf in) 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 extends ChannelInboundByteHandlerAdapter {
   4 
         @Override
   6     public void channelActive(ChannelHandlerContext ctx) {114. How do I pass data between handlers in the same Channel?
          
       
    
-
\ No newline at end of file
+