Rename SimpleChannelInboundHandler.channelRead0() to messageReceived()

- Related: #1590
This commit is contained in:
Trustin Lee 2013-11-02 19:59:21 +09:00
parent 81243c1524
commit 9d611a182f
48 changed files with 64 additions and 58 deletions

View File

@ -75,7 +75,7 @@ public class AppletDiscardServer extends JApplet {
private static final class DiscardServerHandler extends SimpleChannelInboundHandler<ByteBuf> { private static final class DiscardServerHandler extends SimpleChannelInboundHandler<ByteBuf> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
System.out.println("Received: " + msg.toString(CharsetUtil.UTF_8)); System.out.println("Received: " + msg.toString(CharsetUtil.UTF_8));
} }

View File

@ -62,7 +62,7 @@ public class DiscardClientHandler extends SimpleChannelInboundHandler<Object> {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// Server is supposed to send nothing, but if it sends something, discard it. // Server is supposed to send nothing, but if it sends something, discard it.
} }

View File

@ -30,7 +30,7 @@ public class DiscardServerHandler extends SimpleChannelInboundHandler<Object> {
DiscardServerHandler.class.getName()); DiscardServerHandler.class.getName());
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// discard // discard
} }

View File

@ -70,7 +70,7 @@ public class FactorialClientHandler extends SimpleChannelInboundHandler<BigInteg
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, final BigInteger msg) { public void messageReceived(ChannelHandlerContext ctx, final BigInteger msg) {
receivedMessages ++; receivedMessages ++;
if (receivedMessages == count) { if (receivedMessages == count) {
// Offer the answer after closing the connection. // Offer the answer after closing the connection.

View File

@ -39,7 +39,7 @@ public class FactorialServerHandler extends SimpleChannelInboundHandler<BigInteg
private BigInteger factorial = new BigInteger("1"); private BigInteger factorial = new BigInteger("1");
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, BigInteger msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, BigInteger msg) throws Exception {
// Calculate the cumulative factorial and send it to the client. // Calculate the cumulative factorial and send it to the client.
lastMultiplier = msg; lastMultiplier = msg;
factorial = factorial.multiply(msg); factorial = factorial.multiply(msg);

View File

@ -93,7 +93,7 @@ public class FileServer {
private static final class FileHandler extends SimpleChannelInboundHandler<String> { private static final class FileHandler extends SimpleChannelInboundHandler<String> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
File file = new File(msg); File file = new File(msg);
if (file.exists()) { if (file.exists()) {
if (!file.isFile()) { if (!file.isFile()) {

View File

@ -114,7 +114,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
} }
@Override @Override
public void channelRead0( public void messageReceived(
ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
if (!request.getDecoderResult().isSuccess()) { if (!request.getDecoderResult().isSuccess()) {
sendError(ctx, BAD_REQUEST); sendError(ctx, BAD_REQUEST);

View File

@ -27,7 +27,7 @@ import io.netty.util.CharsetUtil;
public class HttpSnoopClientHandler extends SimpleChannelInboundHandler<HttpObject> { public class HttpSnoopClientHandler extends SimpleChannelInboundHandler<HttpObject> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
if (msg instanceof HttpResponse) { if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg; HttpResponse response = (HttpResponse) msg;

View File

@ -55,7 +55,7 @@ public class HttpSnoopServerHandler extends SimpleChannelInboundHandler<Object>
} }
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) { protected void messageReceived(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof HttpRequest) { if (msg instanceof HttpRequest) {
HttpRequest request = this.request = (HttpRequest) msg; HttpRequest request = this.request = (HttpRequest) msg;

View File

@ -36,7 +36,7 @@ public class HttpUploadClientHandler extends SimpleChannelInboundHandler<HttpObj
private boolean readingChunks; private boolean readingChunks;
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
if (msg instanceof HttpResponse) { if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg; HttpResponse response = (HttpResponse) msg;

View File

@ -95,7 +95,7 @@ public class HttpUploadServerHandler extends SimpleChannelInboundHandler<HttpObj
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
if (msg instanceof HttpRequest) { if (msg instanceof HttpRequest) {
HttpRequest request = this.request = (HttpRequest) msg; HttpRequest request = this.request = (HttpRequest) msg;
URI uri = new URI(request.getUri()); URI uri = new URI(request.getUri());

View File

@ -79,7 +79,7 @@ public class WebSocketClientHandler extends SimpleChannelInboundHandler<Object>
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
Channel ch = ctx.channel(); Channel ch = ctx.channel();
if (!handshaker.isHandshakeComplete()) { if (!handshaker.isHandshakeComplete()) {
handshaker.finishHandshake(ch, (FullHttpResponse) msg); handshaker.finishHandshake(ch, (FullHttpResponse) msg);

View File

@ -21,7 +21,7 @@ import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
public class CustomTextFrameHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> { public class CustomTextFrameHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame frame) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, TextWebSocketFrame frame) throws Exception {
String request = frame.text(); String request = frame.text();
ctx.channel().writeAndFlush(new TextWebSocketFrame(request.toUpperCase())); ctx.channel().writeAndFlush(new TextWebSocketFrame(request.toUpperCase()));
} }

View File

@ -53,7 +53,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler<Object>
private WebSocketServerHandshaker handshaker; private WebSocketServerHandshaker handshaker;
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof FullHttpRequest) { if (msg instanceof FullHttpRequest) {
handleHttpRequest(ctx, (FullHttpRequest) msg); handleHttpRequest(ctx, (FullHttpRequest) msg);
} else if (msg instanceof WebSocketFrame) { } else if (msg instanceof WebSocketFrame) {

View File

@ -54,7 +54,7 @@ public class WebSocketSslServerHandler extends SimpleChannelInboundHandler<Objec
private WebSocketServerHandshaker handshaker; private WebSocketServerHandshaker handshaker;
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof FullHttpRequest) { if (msg instanceof FullHttpRequest) {
handleHttpRequest(ctx, (FullHttpRequest) msg); handleHttpRequest(ctx, (FullHttpRequest) msg);
} else if (msg instanceof WebSocketFrame) { } else if (msg instanceof WebSocketFrame) {

View File

@ -21,7 +21,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
public class LocalEchoClientHandler extends SimpleChannelInboundHandler<Object> { public class LocalEchoClientHandler extends SimpleChannelInboundHandler<Object> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// Print as received // Print as received
System.out.println(msg); System.out.println(msg);
} }

View File

@ -23,7 +23,7 @@ import io.netty.util.CharsetUtil;
public class QuoteOfTheMomentClientHandler extends SimpleChannelInboundHandler<DatagramPacket> { public class QuoteOfTheMomentClientHandler extends SimpleChannelInboundHandler<DatagramPacket> {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
String response = msg.content().toString(CharsetUtil.UTF_8); String response = msg.content().toString(CharsetUtil.UTF_8);
if (response.startsWith("QOTM: ")) { if (response.startsWith("QOTM: ")) {
System.out.println("Quote of the Moment: " + response.substring(6)); System.out.println("Quote of the Moment: " + response.substring(6));

View File

@ -44,7 +44,7 @@ public class QuoteOfTheMomentServerHandler extends SimpleChannelInboundHandler<D
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception { public void messageReceived(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception {
System.err.println(packet); System.err.println(packet);
if ("QOTM?".equals(packet.content().toString(CharsetUtil.UTF_8))) { if ("QOTM?".equals(packet.content().toString(CharsetUtil.UTF_8))) {
ctx.write(new DatagramPacket( ctx.write(new DatagramPacket(

View File

@ -26,7 +26,7 @@ public class RxtxClientHandler extends SimpleChannelInboundHandler<String> {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
if ("OK".equals(msg)) { if ("OK".equals(msg)) {
System.out.println("Serial port responded to AT"); System.out.println("Serial port responded to AT");
} else { } else {

View File

@ -30,7 +30,7 @@ public class SecureChatClientHandler extends SimpleChannelInboundHandler<String>
SecureChatClientHandler.class.getName()); SecureChatClientHandler.class.getName());
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
System.err.println(msg); System.err.println(msg);
} }

View File

@ -61,7 +61,7 @@ public class SecureChatServerHandler extends SimpleChannelInboundHandler<String>
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
// Send the received message to all channels but the current one. // Send the received message to all channels but the current one.
for (Channel c: channels) { for (Channel c: channels) {
if (c != ctx.channel()) { if (c != ctx.channel()) {

View File

@ -42,8 +42,8 @@ public final class SocksServerConnectHandler extends SimpleChannelInboundHandler
private final Bootstrap b = new Bootstrap(); private final Bootstrap b = new Bootstrap();
@Override @Override
public void channelRead0(final ChannelHandlerContext ctx, final SocksCmdRequest request) throws Exception { public void messageReceived(final ChannelHandlerContext ctx, final SocksCmdRequest request) throws Exception {
Promise promise = ctx.executor().newPromise(); Promise<Channel> promise = ctx.executor().newPromise();
promise.addListener( promise.addListener(
new GenericFutureListener<Future<Channel>>() { new GenericFutureListener<Future<Channel>>() {
@Override @Override

View File

@ -37,7 +37,7 @@ public final class SocksServerHandler extends SimpleChannelInboundHandler<SocksR
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception { public void messageReceived(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception {
switch (socksRequest.requestType()) { switch (socksRequest.requestType()) {
case INIT: { case INIT: {
// auth support example // auth support example

View File

@ -31,7 +31,7 @@ public class TelnetClientHandler extends SimpleChannelInboundHandler<String> {
private static final Logger logger = Logger.getLogger(TelnetClientHandler.class.getName()); private static final Logger logger = Logger.getLogger(TelnetClientHandler.class.getName());
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
System.err.println(msg); System.err.println(msg);
} }

View File

@ -44,7 +44,7 @@ public class TelnetServerHandler extends SimpleChannelInboundHandler<String> {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String request) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String request) throws Exception {
// Generate and write a response. // Generate and write a response.
String response; String response;

View File

@ -58,7 +58,7 @@ public class ByteEchoClientHandler extends SimpleChannelInboundHandler<ByteBuf>
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
meter.mark(msg.readableBytes()); meter.mark(msg.readableBytes());
ctx.write(msg); ctx.write(msg);

View File

@ -65,7 +65,7 @@ public class MsgEchoClientHandler extends SimpleChannelInboundHandler<UdtMessage
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, UdtMessage msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, UdtMessage msg) throws Exception {
meter.mark(msg.content().readableBytes()); meter.mark(msg.content().readableBytes());
ctx.write(msg); ctx.write(msg);

View File

@ -66,7 +66,7 @@ public class MsgEchoPeerHandler extends
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, UdtMessage message) throws Exception { public void messageReceived(ChannelHandlerContext ctx, UdtMessage message) throws Exception {
meter.mark(message.content().readableBytes()); meter.mark(message.content().readableBytes());
ctx.write(message); ctx.write(message);

View File

@ -60,7 +60,7 @@ public class ByteEchoPeerHandler extends SimpleChannelInboundHandler<ByteBuf> {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf buf) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
meter.mark(buf.readableBytes()); meter.mark(buf.readableBytes());
ctx.write(buf); ctx.write(buf);

View File

@ -49,7 +49,7 @@ public class UptimeClientHandler extends SimpleChannelInboundHandler<Object> {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// Discard received data // Discard received data
} }

View File

@ -99,7 +99,7 @@ public class WorldClockClientHandler extends SimpleChannelInboundHandler<LocalTi
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, LocalTimes times) throws Exception { public void messageReceived(ChannelHandlerContext ctx, LocalTimes times) throws Exception {
answer.add(times); answer.add(times);
} }

View File

@ -37,7 +37,7 @@ public class WorldClockServerHandler extends SimpleChannelInboundHandler<Locatio
WorldClockServerHandler.class.getName()); WorldClockServerHandler.class.getName());
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Locations locations) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Locations locations) throws Exception {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
LocalTimes.Builder builder = LocalTimes.newBuilder(); LocalTimes.Builder builder = LocalTimes.newBuilder();

View File

@ -149,7 +149,7 @@ public class SctpEchoTest extends AbstractSctpTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);

View File

@ -45,7 +45,7 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
sb.handler(new SimpleChannelInboundHandler<Object>() { sb.handler(new SimpleChannelInboundHandler<Object>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// Nothing will be sent. // Nothing will be sent.
} }
}); });
@ -97,7 +97,7 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
private volatile boolean fail; private volatile boolean fail;
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { protected void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
if (done) { if (done) {
fail = true; fail = true;
} }

View File

@ -41,7 +41,7 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
sb.handler(new SimpleChannelInboundHandler<DatagramPacket>() { sb.handler(new SimpleChannelInboundHandler<DatagramPacket>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
assertEquals(1, msg.content().readInt()); assertEquals(1, msg.content().readInt());
latch.countDown(); latch.countDown();
} }
@ -49,7 +49,7 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
cb.handler(new SimpleChannelInboundHandler<Object>() { cb.handler(new SimpleChannelInboundHandler<Object>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msgs) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msgs) throws Exception {
// Nothing will be sent. // Nothing will be sent.
} }
}); });
@ -69,12 +69,13 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
run(); run();
} }
@SuppressWarnings("deprecation")
public void testSimpleSendWithoutBind(Bootstrap sb, Bootstrap cb) throws Throwable { public void testSimpleSendWithoutBind(Bootstrap sb, Bootstrap cb) throws Throwable {
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
sb.handler(new SimpleChannelInboundHandler<DatagramPacket>() { sb.handler(new SimpleChannelInboundHandler<DatagramPacket>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
assertEquals(1, msg.content().readInt()); assertEquals(1, msg.content().readInt());
latch.countDown(); latch.countDown();
} }
@ -82,7 +83,7 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
cb.handler(new SimpleChannelInboundHandler<Object>() { cb.handler(new SimpleChannelInboundHandler<Object>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msgs) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msgs) throws Exception {
// Nothing will be sent. // Nothing will be sent.
} }
}); });

View File

@ -96,7 +96,7 @@ public class SocketBufReleaseTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
// discard // discard
} }

View File

@ -199,7 +199,7 @@ public class SocketEchoTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);

View File

@ -72,7 +72,7 @@ public class SocketFileRegionTest extends AbstractSocketTest {
ChannelInboundHandler ch = new SimpleChannelInboundHandler<Object>() { ChannelInboundHandler ch = new SimpleChannelInboundHandler<Object>() {
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
} }
@Override @Override
@ -131,7 +131,7 @@ public class SocketFileRegionTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);

View File

@ -134,7 +134,7 @@ public class SocketFixedLengthEchoTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
assertEquals(1024, msg.readableBytes()); assertEquals(1024, msg.readableBytes());
byte[] actual = new byte[msg.readableBytes()]; byte[] actual = new byte[msg.readableBytes()];

View File

@ -132,7 +132,7 @@ public class SocketGatheringWriteTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
counter += in.readableBytes(); counter += in.readableBytes();
received.writeBytes(in); received.writeBytes(in);
} }

View File

@ -127,7 +127,7 @@ public class SocketShutdownOutputByPeerTest extends AbstractServerSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
queue.offer(msg.readByte()); queue.offer(msg.readByte());
} }

View File

@ -86,7 +86,7 @@ public class SocketShutdownOutputBySelfTest extends AbstractClientSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
queue.offer(msg.readByte()); queue.offer(msg.readByte());
} }
} }

View File

@ -251,7 +251,7 @@ public class SocketSpdyEchoTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);

View File

@ -205,7 +205,7 @@ public class SocketSslEchoTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { public void messageReceived(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
byte[] actual = new byte[in.readableBytes()]; byte[] actual = new byte[in.readableBytes()];
in.readBytes(actual); in.readBytes(actual);

View File

@ -159,7 +159,7 @@ public class SocketStartTlsTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
if ("StartTlsResponse".equals(msg)) { if ("StartTlsResponse".equals(msg)) {
ctx.pipeline().addAfter("logger", "ssl", sslHandler); ctx.pipeline().addAfter("logger", "ssl", sslHandler);
handshakeFuture = sslHandler.handshakeFuture(); handshakeFuture = sslHandler.handshakeFuture();
@ -201,7 +201,7 @@ public class SocketStartTlsTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
if ("StartTlsRequest".equals(msg)) { if ("StartTlsRequest".equals(msg)) {
ctx.pipeline().addAfter("logger", "ssl", sslHandler); ctx.pipeline().addAfter("logger", "ssl", sslHandler);
ctx.writeAndFlush("StartTlsResponse\n"); ctx.writeAndFlush("StartTlsResponse\n");

View File

@ -146,7 +146,7 @@ public class SocketStringEchoTest extends AbstractSocketTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
assertEquals(data[counter], msg); assertEquals(data[counter], msg);
if (channel.parent() != null) { if (channel.parent() != null) {

View File

@ -167,7 +167,7 @@ public class UDTClientServerConnectionTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
log.info("Client received: " + msg); log.info("Client received: " + msg);
} }
} }
@ -320,7 +320,7 @@ public class UDTClientServerConnectionTest {
} }
@Override @Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
log.info("Server received: " + msg); log.info("Server received: " + msg);
} }
} }

View File

@ -28,7 +28,7 @@ import io.netty.util.internal.TypeParameterMatcher;
* {@link SimpleChannelInboundHandler}&lt;{@link String}&gt; { * {@link SimpleChannelInboundHandler}&lt;{@link String}&gt; {
* *
* {@code @Override} * {@code @Override}
* protected void channelRead0({@link ChannelHandlerContext} ctx, {@link String} message) * protected void messageReceived({@link ChannelHandlerContext} ctx, {@link String} message)
* throws {@link Exception} { * throws {@link Exception} {
* System.out.println(message); * System.out.println(message);
* } * }
@ -37,6 +37,11 @@ import io.netty.util.internal.TypeParameterMatcher;
* *
* Be aware that depending of the constructor parameters it will release all handled messages. * Be aware that depending of the constructor parameters it will release all handled messages.
* *
* <h3>Backward compatibility consideration</h3>
* <p>
* Since 5.0, {@code channelRead0(ChannelHandlerContext, I)} has been renamed to
* {@link #messageReceived(ChannelHandlerContext, Object)}.
* </p>
*/ */
public abstract class SimpleChannelInboundHandler<I> extends ChannelInboundHandlerAdapter { public abstract class SimpleChannelInboundHandler<I> extends ChannelInboundHandlerAdapter {
@ -95,7 +100,7 @@ public abstract class SimpleChannelInboundHandler<I> extends ChannelInboundHandl
if (acceptInboundMessage(msg)) { if (acceptInboundMessage(msg)) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
I imsg = (I) msg; I imsg = (I) msg;
channelRead0(ctx, imsg); messageReceived(ctx, imsg);
} else { } else {
release = false; release = false;
ctx.fireChannelRead(msg); ctx.fireChannelRead(msg);
@ -115,5 +120,5 @@ public abstract class SimpleChannelInboundHandler<I> extends ChannelInboundHandl
* @param msg the message to handle * @param msg the message to handle
* @throws Exception is thrown if an error occurred * @throws Exception is thrown if an error occurred
*/ */
protected abstract void channelRead0(ChannelHandlerContext ctx, I msg) throws Exception; protected abstract void messageReceived(ChannelHandlerContext ctx, I msg) throws Exception;
} }