diff --git a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopClientHandler.java b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopClientHandler.java index 9ca5f35f4e..289432ff89 100644 --- a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopClientHandler.java +++ b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopClientHandler.java @@ -18,15 +18,13 @@ package io.netty.example.http.snoop; import io.netty.buffer.ChannelBuffer; import io.netty.channel.ChannelBufferHolder; import io.netty.channel.ChannelBufferHolders; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInboundHandlerContext; +import io.netty.channel.ChannelInboundMessageHandlerAdapter; import io.netty.handler.codec.http.HttpChunk; import io.netty.handler.codec.http.HttpResponse; import io.netty.util.CharsetUtil; -import java.util.Queue; - -public class HttpSnoopClientHandler extends ChannelInboundHandlerAdapter { +public class HttpSnoopClientHandler extends ChannelInboundMessageHandlerAdapter { private boolean readingChunks; @@ -39,19 +37,7 @@ public class HttpSnoopClientHandler extends ChannelInboundHandlerAdapter @Override - public void inboundBufferUpdated(ChannelInboundHandlerContext ctx) - throws Exception { - Queue in = ctx.in().messageBuffer(); - while (handleMessage(in.poll())) { - continue; - } - } - - private boolean handleMessage(Object msg) throws Exception { - if (msg == null) { - return false; - } - + public void messageReceived(ChannelInboundHandlerContext ctx, Object msg) throws Exception { if (!readingChunks) { HttpResponse response = (HttpResponse) msg; @@ -89,8 +75,6 @@ public class HttpSnoopClientHandler extends ChannelInboundHandlerAdapter System.out.flush(); } } - - return true; } @Override diff --git a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java index 3c00146a64..06a24c5f8b 100644 --- a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java +++ b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java @@ -25,8 +25,8 @@ import io.netty.channel.ChannelBufferHolder; import io.netty.channel.ChannelBufferHolders; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; -import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInboundHandlerContext; +import io.netty.channel.ChannelInboundMessageHandlerAdapter; import io.netty.handler.codec.http.Cookie; import io.netty.handler.codec.http.CookieDecoder; import io.netty.handler.codec.http.CookieEncoder; @@ -42,10 +42,9 @@ import io.netty.util.CharsetUtil; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Queue; import java.util.Set; -public class HttpSnoopServerHandler extends ChannelInboundHandlerAdapter { +public class HttpSnoopServerHandler extends ChannelInboundMessageHandlerAdapter { private HttpRequest request; private boolean readingChunks; @@ -59,19 +58,7 @@ public class HttpSnoopServerHandler extends ChannelInboundHandlerAdapter } @Override - public void inboundBufferUpdated(ChannelInboundHandlerContext ctx) - throws Exception { - Queue in = ctx.in().messageBuffer(); - while (handleMessage(ctx, in.poll())) { - continue; - } - } - - private boolean handleMessage(ChannelInboundHandlerContext ctx, Object msg) throws Exception { - if (msg == null) { - return false; - } - + public void messageReceived(ChannelInboundHandlerContext ctx, Object msg) throws Exception { if (!readingChunks) { HttpRequest request = this.request = (HttpRequest) msg; @@ -136,8 +123,6 @@ public class HttpSnoopServerHandler extends ChannelInboundHandlerAdapter buf.append("CHUNK: " + chunk.getContent().toString(CharsetUtil.UTF_8) + "\r\n"); } } - - return true; } private void writeResponse(ChannelInboundHandlerContext ctx) {