From 3584da2dad941257d0608cf12e80e285fb0b8a99 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 31 May 2012 09:04:19 -0700 Subject: [PATCH] Use ChannelInboundStreamHandlerAdapter in EchoClientHandler --- .../io/netty/example/echo/EchoClientHandler.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/example/src/main/java/io/netty/example/echo/EchoClientHandler.java b/example/src/main/java/io/netty/example/echo/EchoClientHandler.java index e84ffc9c56..43d0e0d80a 100644 --- a/example/src/main/java/io/netty/example/echo/EchoClientHandler.java +++ b/example/src/main/java/io/netty/example/echo/EchoClientHandler.java @@ -17,10 +17,8 @@ package io.netty.example.echo; import io.netty.buffer.ChannelBuffer; import io.netty.buffer.ChannelBuffers; -import io.netty.channel.ChannelBufferHolder; -import io.netty.channel.ChannelBufferHolders; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInboundHandlerContext; +import io.netty.channel.ChannelInboundStreamHandlerAdapter; import java.util.logging.Level; import java.util.logging.Logger; @@ -30,7 +28,7 @@ import java.util.logging.Logger; * traffic between the echo client and server by sending the first message to * the server. */ -public class EchoClientHandler extends ChannelInboundHandlerAdapter { +public class EchoClientHandler extends ChannelInboundStreamHandlerAdapter { private static final Logger logger = Logger.getLogger( EchoClientHandler.class.getName()); @@ -50,23 +48,16 @@ public class EchoClientHandler extends ChannelInboundHandlerAdapter { } } - @Override - public ChannelBufferHolder newInboundBuffer(ChannelInboundHandlerContext ctx) { - return ChannelBufferHolders.byteBuffer(); - } - @Override public void channelActive(ChannelInboundHandlerContext ctx) { ctx.write(firstMessage); } @Override - public void inboundBufferUpdated(ChannelInboundHandlerContext ctx) { - ChannelBuffer in = ctx.inbound().byteBuffer(); + public void inboundBufferUpdated(ChannelInboundHandlerContext ctx, ChannelBuffer in) { ChannelBuffer out = ctx.nextOutboundByteBuffer(); out.discardReadBytes(); out.writeBytes(in); - in.discardReadBytes(); ctx.flush(); }