Remove channelReadSuspended / Rename messageReceived(Last) to channelRead(Complete)
- Remove channelReadSuspended because it's actually same with messageReceivedLast - Rename messageReceived to channelRead - Rename messageReceivedLast to channelReadComplete We renamed messageReceivedLast to channelReadComplete because it reflects what it really is for. Also, we renamed messageReceived to channelRead for consistency in method names.
This commit is contained in:
parent
354de0a8f0
commit
26e9d70457
@ -45,9 +45,9 @@ class WebSocketClientProtocolHandshakeHandler extends ChannelInboundHandlerAdapt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (!(msg instanceof FullHttpResponse)) {
|
||||
ctx.fireMessageReceived(msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.websocketx;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
@ -31,6 +30,8 @@ import io.netty.util.AttributeKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpVersion.*;
|
||||
|
||||
/**
|
||||
* This handler does all the heavy lifting for you to run a websocket server.
|
||||
*
|
||||
@ -123,13 +124,13 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler {
|
||||
static ChannelHandler forbiddenHttpRequestResponder() {
|
||||
return new ChannelInboundHandlerAdapter() {
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof FullHttpRequest) {
|
||||
FullHttpResponse response =
|
||||
new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.FORBIDDEN);
|
||||
ctx.channel().write(response).flush();
|
||||
} else {
|
||||
ctx.fireMessageReceived(msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -50,7 +50,7 @@ class WebSocketServerProtocolHandshakeHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
FullHttpRequest req = (FullHttpRequest) msg;
|
||||
if (req.getMethod() != GET) {
|
||||
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN));
|
||||
|
@ -60,13 +60,13 @@ public abstract class SpdyOrHttpChooser extends ChannelInboundHandlerAdapter {
|
||||
protected abstract SelectedProtocol getProtocol(SSLEngine engine);
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (initPipeline(ctx)) {
|
||||
// When we reached here we can remove this handler as its now clear what protocol we want to use
|
||||
// from this point on.
|
||||
ctx.pipeline().remove(this);
|
||||
|
||||
ctx.fireMessageReceived(msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ final class SpdySession {
|
||||
}
|
||||
|
||||
/*
|
||||
* hasReceivedReply and receivedReply are only called from messageReceived
|
||||
* hasReceivedReply and receivedReply are only called from channelRead()
|
||||
* no need to synchronize access to the StreamState
|
||||
*/
|
||||
boolean hasReceivedReply(int streamID) {
|
||||
|
@ -84,7 +84,7 @@ public class SpdySessionHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof SpdyDataFrame) {
|
||||
|
||||
/*
|
||||
@ -378,7 +378,7 @@ public class SpdySessionHandler
|
||||
}
|
||||
}
|
||||
|
||||
ctx.fireMessageReceived(msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -658,13 +658,13 @@ public class SpdySessionHandler
|
||||
* Note: this is only called by the worker thread
|
||||
*/
|
||||
private void issueStreamError(ChannelHandlerContext ctx, int streamId, SpdyStreamStatus status) {
|
||||
boolean fireMessageReceived = !spdySession.isRemoteSideClosed(streamId);
|
||||
boolean fireChannelRead = !spdySession.isRemoteSideClosed(streamId);
|
||||
removeStream(ctx, streamId);
|
||||
|
||||
SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, status);
|
||||
ctx.write(spdyRstStreamFrame).flush();
|
||||
if (fireMessageReceived) {
|
||||
ctx.fireMessageReceived(spdyRstStreamFrame);
|
||||
if (fireChannelRead) {
|
||||
ctx.fireChannelRead(spdyRstStreamFrame);
|
||||
}
|
||||
}
|
||||
|
||||
@ -800,7 +800,7 @@ public class SpdySessionHandler
|
||||
halfCloseStream(streamId, false);
|
||||
}
|
||||
|
||||
ctx.fireMessageReceived(spdyDataFrame);
|
||||
ctx.fireChannelRead(spdyDataFrame);
|
||||
} else {
|
||||
// We can send a partial frame
|
||||
spdySession.updateSendWindowSize(streamId, -1 * newWindowSize);
|
||||
@ -826,7 +826,7 @@ public class SpdySessionHandler
|
||||
// }
|
||||
//});
|
||||
|
||||
ctx.fireMessageReceived(partialDataFrame);
|
||||
ctx.fireChannelRead(partialDataFrame);
|
||||
|
||||
newWindowSize = 0;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class HttpObjectAggregatorTest {
|
||||
assertFalse(embedder.writeInbound(chunk1));
|
||||
assertFalse(embedder.writeInbound(chunk2));
|
||||
|
||||
// this should trigger a messageReceived event so return true
|
||||
// this should trigger a channelRead event so return true
|
||||
assertTrue(embedder.writeInbound(chunk3));
|
||||
assertTrue(embedder.finish());
|
||||
DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound();
|
||||
@ -87,7 +87,7 @@ public class HttpObjectAggregatorTest {
|
||||
assertFalse(embedder.writeInbound(chunk1));
|
||||
assertFalse(embedder.writeInbound(chunk2));
|
||||
|
||||
// this should trigger a messageReceived event so return true
|
||||
// this should trigger a channelRead event so return true
|
||||
assertTrue(embedder.writeInbound(trailer));
|
||||
assertTrue(embedder.finish());
|
||||
DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound();
|
||||
@ -172,7 +172,7 @@ public class HttpObjectAggregatorTest {
|
||||
assertFalse(embedder.writeInbound(chunk1));
|
||||
assertFalse(embedder.writeInbound(chunk2));
|
||||
|
||||
// this should trigger a messageReceived event so return true
|
||||
// this should trigger a channelRead event so return true
|
||||
assertTrue(embedder.writeInbound(chunk3));
|
||||
assertTrue(embedder.finish());
|
||||
FullHttpRequest aggratedMessage = (FullHttpRequest) embedder.readInbound();
|
||||
|
@ -160,7 +160,7 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
private String content;
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
assertNull(content);
|
||||
content = "processed: " + ((TextWebSocketFrame) msg).text();
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class SpdyFrameDecoderTest {
|
||||
public volatile Object message;
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object m) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object m) throws Exception {
|
||||
message = m;
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ public class SpdySessionHandlerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof SpdySynStreamFrame) {
|
||||
|
||||
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
|
||||
|
@ -78,8 +78,8 @@ public abstract class ByteToMessageCodec<I> extends ChannelDuplexHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
decoder.messageReceived(ctx, msg);
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
decoder.channelRead(ctx, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +56,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
}
|
||||
|
||||
/**
|
||||
* If set then only one message is decoded on each {@link #messageReceived(ChannelHandlerContext, Object)}
|
||||
* If set then only one message is decoded on each {@link #channelRead(ChannelHandlerContext, Object)}
|
||||
* call. This may be useful if you need to do some protocol upgrade and want to make sure nothing is mixed up.
|
||||
*
|
||||
* Default is {@code false} as this has performance impacts.
|
||||
@ -67,7 +67,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
|
||||
/**
|
||||
* If {@code true} then only one message is decoded on each
|
||||
* {@link #messageReceived(ChannelHandlerContext, Object)} call.
|
||||
* {@link #channelRead(ChannelHandlerContext, Object)} call.
|
||||
*
|
||||
* Default is {@code false} as this has performance impacts.
|
||||
*/
|
||||
@ -102,9 +102,9 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
public final void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
|
||||
ByteBuf buf = internalBuffer();
|
||||
if (buf.isReadable()) {
|
||||
ctx.fireMessageReceived(buf);
|
||||
ctx.fireChannelRead(buf);
|
||||
}
|
||||
ctx.fireMessageReceivedLast();
|
||||
ctx.fireChannelReadComplete();
|
||||
handlerRemoved0(ctx);
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
protected void handlerRemoved0(ChannelHandlerContext ctx) throws Exception { }
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
CodecOutput out = CodecOutput.newInstance();
|
||||
try {
|
||||
if (msg instanceof ByteBuf) {
|
||||
@ -163,7 +163,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
}
|
||||
|
||||
for (int i = 0; i < out.size(); i ++) {
|
||||
ctx.fireMessageReceived(out.get(i));
|
||||
ctx.fireChannelRead(out.get(i));
|
||||
}
|
||||
|
||||
out.recycle();
|
||||
@ -171,14 +171,14 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelReadSuspended(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
if (decodeWasNull) {
|
||||
decodeWasNull = false;
|
||||
if (!ctx.channel().config().isAutoRead()) {
|
||||
ctx.read();
|
||||
}
|
||||
}
|
||||
super.channelReadSuspended(ctx);
|
||||
ctx.fireChannelReadComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -202,7 +202,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
}
|
||||
|
||||
for (int i = 0; i < out.size(); i ++) {
|
||||
ctx.fireMessageReceived(out.get(i));
|
||||
ctx.fireChannelRead(out.get(i));
|
||||
}
|
||||
ctx.fireChannelInactive();
|
||||
}
|
||||
@ -256,7 +256,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
* Is called one last time when the {@link ChannelHandlerContext} goes in-active. Which means the
|
||||
* {@link #channelInactive(ChannelHandlerContext)} was triggered.
|
||||
*
|
||||
* By default this will just call {@link #decode(ChannelHandlerContext, ByteBuf, CodecOutput)} but sub-classes may
|
||||
* By default this will just call {@link #decode(ChannelHandlerContext, ByteBuf, List)} but sub-classes may
|
||||
* override this for some special cleanup operation.
|
||||
*/
|
||||
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||
|
@ -96,8 +96,8 @@ public abstract class MessageToMessageCodec<INBOUND_IN, OUTBOUND_IN> extends Cha
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
decoder.messageReceived(ctx, msg);
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
decoder.channelRead(ctx, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,13 +124,13 @@ public abstract class MessageToMessageCodec<INBOUND_IN, OUTBOUND_IN> extends Cha
|
||||
}
|
||||
|
||||
/**
|
||||
* @see MessageToMessageEncoder#encode(ChannelHandlerContext, Object, CodecOutput)
|
||||
* @see MessageToMessageEncoder#encode(ChannelHandlerContext, Object, List)
|
||||
*/
|
||||
protected abstract void encode(ChannelHandlerContext ctx, OUTBOUND_IN msg, List<Object> out)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* @see MessageToMessageDecoder#decode(ChannelHandlerContext, Object, CodecOutput)
|
||||
* @see MessageToMessageDecoder#decode(ChannelHandlerContext, Object, List)
|
||||
*/
|
||||
protected abstract void decode(ChannelHandlerContext ctx, INBOUND_IN msg, List<Object> out)
|
||||
throws Exception;
|
||||
|
@ -64,7 +64,7 @@ public abstract class MessageToMessageDecoder<I> extends ChannelInboundHandlerAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
CodecOutput out = CodecOutput.newInstance();
|
||||
try {
|
||||
if (acceptInboundMessage(msg)) {
|
||||
@ -84,7 +84,7 @@ public abstract class MessageToMessageDecoder<I> extends ChannelInboundHandlerAd
|
||||
throw new DecoderException(e);
|
||||
} finally {
|
||||
for (int i = 0; i < out.size(); i ++) {
|
||||
ctx.fireMessageReceived(out.get(i));
|
||||
ctx.fireChannelRead(out.get(i));
|
||||
}
|
||||
out.recycle();
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ public abstract class ReplayingDecoder<S> extends ByteToMessageDecoder {
|
||||
}
|
||||
|
||||
for (int i = 0; i < out.size(); i ++) {
|
||||
ctx.fireMessageReceived(out.get(i));
|
||||
ctx.fireChannelRead(out.get(i));
|
||||
}
|
||||
ctx.fireChannelInactive();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ import java.util.List;
|
||||
* and then you can use an array of bytes instead of a {@link ByteBuf}
|
||||
* as a message:
|
||||
* <pre>
|
||||
* void messageReceived({@link ChannelHandlerContext} ctx, byte[] bytes) {
|
||||
* void channelRead({@link ChannelHandlerContext} ctx, byte[] bytes) {
|
||||
* ...
|
||||
* }
|
||||
* </pre>
|
||||
|
@ -45,7 +45,7 @@ import java.util.List;
|
||||
* and then you can use an array of bytes instead of a {@link ByteBuf}
|
||||
* as a message:
|
||||
* <pre>
|
||||
* void messageReceived({@link ChannelHandlerContext} ctx, byte[] bytes) {
|
||||
* void channelRead({@link ChannelHandlerContext} ctx, byte[] bytes) {
|
||||
* ...
|
||||
* }
|
||||
* </pre>
|
||||
|
@ -15,6 +15,9 @@
|
||||
*/
|
||||
package io.netty.handler.codec.protobuf;
|
||||
|
||||
import com.google.protobuf.ExtensionRegistry;
|
||||
import com.google.protobuf.Message;
|
||||
import com.google.protobuf.MessageLite;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -26,10 +29,6 @@ import io.netty.handler.codec.MessageToMessageDecoder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.protobuf.ExtensionRegistry;
|
||||
import com.google.protobuf.Message;
|
||||
import com.google.protobuf.MessageLite;
|
||||
|
||||
/**
|
||||
* Decodes a received {@link ByteBuf} into a
|
||||
* <a href="http://code.google.com/p/protobuf/">Google Protocol Buffers</a>
|
||||
@ -53,7 +52,7 @@ import com.google.protobuf.MessageLite;
|
||||
* and then you can use a {@code MyMessage} instead of a {@link ByteBuf}
|
||||
* as a message:
|
||||
* <pre>
|
||||
* void messageReceived({@link ChannelHandlerContext} ctx, MyMessage req) {
|
||||
* void channelRead({@link ChannelHandlerContext} ctx, MyMessage req) {
|
||||
* MyMessage res = MyMessage.newBuilder().setText(
|
||||
* "Did you say '" + req.getText() + "'?").build();
|
||||
* ch.write(res);
|
||||
|
@ -15,7 +15,9 @@
|
||||
*/
|
||||
package io.netty.handler.codec.protobuf;
|
||||
|
||||
import static io.netty.buffer.Unpooled.wrappedBuffer;
|
||||
import com.google.protobuf.Message;
|
||||
import com.google.protobuf.MessageLite;
|
||||
import com.google.protobuf.MessageLiteOrBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -26,9 +28,7 @@ import io.netty.handler.codec.MessageToMessageEncoder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import com.google.protobuf.MessageLite;
|
||||
import com.google.protobuf.MessageLiteOrBuilder;
|
||||
import static io.netty.buffer.Unpooled.*;
|
||||
|
||||
/**
|
||||
* Encodes the requested <a href="http://code.google.com/p/protobuf/">Google
|
||||
@ -50,7 +50,7 @@ import com.google.protobuf.MessageLiteOrBuilder;
|
||||
* and then you can use a {@code MyMessage} instead of a {@link ByteBuf}
|
||||
* as a message:
|
||||
* <pre>
|
||||
* void messageReceived({@link ChannelHandlerContext} ctx, MyMessage req) {
|
||||
* void channelRead({@link ChannelHandlerContext} ctx, MyMessage req) {
|
||||
* MyMessage res = MyMessage.newBuilder().setText(
|
||||
* "Did you say '" + req.getText() + "'?").build();
|
||||
* ch.write(res);
|
||||
|
@ -46,7 +46,7 @@ import java.util.List;
|
||||
* and then you can use a {@link String} instead of a {@link ByteBuf}
|
||||
* as a message:
|
||||
* <pre>
|
||||
* void messageReceived({@link ChannelHandlerContext} ctx, {@link String} msg) {
|
||||
* void channelRead({@link ChannelHandlerContext} ctx, {@link String} msg) {
|
||||
* ch.write("Did you say '" + msg + "'?\n");
|
||||
* }
|
||||
* </pre>
|
||||
|
@ -41,7 +41,7 @@ import java.nio.charset.Charset;
|
||||
* and then you can use a {@link String} instead of a {@link ByteBuf}
|
||||
* as a message:
|
||||
* <pre>
|
||||
* void messageReceived({@link ChannelHandlerContext} ctx, {@link String} msg) {
|
||||
* void channelRead({@link ChannelHandlerContext} ctx, {@link String} msg) {
|
||||
* ch.write("Did you say '" + msg + "'?\n");
|
||||
* }
|
||||
* </pre>
|
||||
|
@ -15,17 +15,16 @@
|
||||
*/
|
||||
package io.netty.handler.codec;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ReplayingDecoderTest {
|
||||
|
||||
@ -82,9 +81,9 @@ public class ReplayingDecoderTest {
|
||||
|
||||
private static final class BloatedLineDecoder extends ChannelInboundHandlerAdapter {
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.pipeline().replace(this, "less-bloated", new LineDecoder());
|
||||
ctx.pipeline().fireMessageReceived(msg);
|
||||
ctx.pipeline().fireChannelRead(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class AppletDiscardServer extends JApplet {
|
||||
private static final class DiscardServerHandler extends SimpleChannelInboundHandler<ByteBuf> {
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||
System.out.println("Received: " + msg.toString(CharsetUtil.UTF_8));
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class DiscardClientHandler extends SimpleChannelInboundHandler<Object> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
// Server is supposed to send nothing, but if it sends something, discard it.
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class DiscardServerHandler extends SimpleChannelInboundHandler<Object> {
|
||||
DiscardServerHandler.class.getName());
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
// discard
|
||||
}
|
||||
|
||||
|
@ -54,12 +54,12 @@ public class EchoClientHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,12 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
|
||||
EchoServerHandler.class.getName());
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,6 @@ public class FactorialClientHandler extends SimpleChannelInboundHandler<BigInteg
|
||||
FactorialClientHandler.class.getName());
|
||||
|
||||
private ChannelHandlerContext ctx;
|
||||
private int i = 1;
|
||||
private int receivedMessages;
|
||||
private final int count;
|
||||
final BlockingQueue<BigInteger> answer = new LinkedBlockingQueue<BigInteger>();
|
||||
@ -70,7 +69,7 @@ public class FactorialClientHandler extends SimpleChannelInboundHandler<BigInteg
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, final BigInteger msg) {
|
||||
public void channelRead0(ChannelHandlerContext ctx, final BigInteger msg) {
|
||||
receivedMessages ++;
|
||||
if (receivedMessages == count) {
|
||||
// Offer the answer after closing the connection.
|
||||
|
@ -39,7 +39,7 @@ public class FactorialServerHandler extends SimpleChannelInboundHandler<BigInteg
|
||||
private BigInteger factorial = new BigInteger("1");
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, BigInteger msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, BigInteger msg) throws Exception {
|
||||
// Calculate the cumulative factorial and send it to the client.
|
||||
lastMultiplier = msg;
|
||||
factorial = factorial.multiply(msg);
|
||||
|
@ -93,7 +93,7 @@ public class FileServer {
|
||||
|
||||
private static final class FileHandler extends SimpleChannelInboundHandler<String> {
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
File file = new File(msg);
|
||||
if (file.exists()) {
|
||||
if (!file.isFile()) {
|
||||
|
@ -104,7 +104,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
|
||||
public static final int HTTP_CACHE_SECONDS = 60;
|
||||
|
||||
@Override
|
||||
public void messageReceived0(
|
||||
public void channelRead0(
|
||||
ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
|
||||
if (!request.getDecoderResult().isSuccess()) {
|
||||
sendError(ctx, BAD_REQUEST);
|
||||
|
@ -35,12 +35,12 @@ public class HttpHelloWorldServerHandler extends ChannelInboundHandlerAdapter {
|
||||
Unpooled.unreleasableBuffer(Unpooled.copiedBuffer("Hello World", CharsetUtil.US_ASCII));
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof HttpRequest) {
|
||||
HttpRequest req = (HttpRequest) msg;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import io.netty.util.CharsetUtil;
|
||||
public class HttpSnoopClientHandler extends SimpleChannelInboundHandler<HttpObject> {
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
|
||||
if (msg instanceof HttpResponse) {
|
||||
HttpResponse response = (HttpResponse) msg;
|
||||
|
||||
|
@ -50,12 +50,12 @@ public class HttpSnoopServerHandler extends SimpleChannelInboundHandler<Object>
|
||||
private final StringBuilder buf = new StringBuilder();
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void messageReceived0(ChannelHandlerContext ctx, Object msg) {
|
||||
protected void channelRead0(ChannelHandlerContext ctx, Object msg) {
|
||||
if (msg instanceof HttpRequest) {
|
||||
HttpRequest request = this.request = (HttpRequest) msg;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class HttpUploadClientHandler extends SimpleChannelInboundHandler<HttpObj
|
||||
private boolean readingChunks;
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
|
||||
if (msg instanceof HttpResponse) {
|
||||
HttpResponse response = (HttpResponse) msg;
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class HttpUploadServerHandler extends SimpleChannelInboundHandler<HttpObj
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
|
||||
if (msg instanceof HttpRequest) {
|
||||
HttpRequest request = this.request = (HttpRequest) msg;
|
||||
URI uri = new URI(request.getUri());
|
||||
|
@ -52,7 +52,7 @@ public class AutobahnServerHandler extends ChannelInboundHandlerAdapter {
|
||||
private WebSocketServerHandshaker handshaker;
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof FullHttpRequest) {
|
||||
handleHttpRequest(ctx, (FullHttpRequest) msg);
|
||||
} else if (msg instanceof WebSocketFrame) {
|
||||
@ -61,7 +61,7 @@ public class AutobahnServerHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class WebSocketClientHandler extends SimpleChannelInboundHandler<Object>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
Channel ch = ctx.channel();
|
||||
if (!handshaker.isHandshakeComplete()) {
|
||||
handshaker.finishHandshake(ch, (FullHttpResponse) msg);
|
||||
|
@ -21,7 +21,7 @@ import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||
|
||||
public class CustomTextFrameHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
|
||||
@Override
|
||||
protected void messageReceived0(ChannelHandlerContext ctx, TextWebSocketFrame frame) throws Exception {
|
||||
protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame frame) throws Exception {
|
||||
String request = frame.text();
|
||||
ctx.channel().write(new TextWebSocketFrame(request.toUpperCase()));
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler<Object>
|
||||
private WebSocketServerHandshaker handshaker;
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof FullHttpRequest) {
|
||||
handleHttpRequest(ctx, (FullHttpRequest) msg);
|
||||
} else if (msg instanceof WebSocketFrame) {
|
||||
|
@ -54,7 +54,7 @@ public class WebSocketSslServerHandler extends SimpleChannelInboundHandler<Objec
|
||||
private WebSocketServerHandshaker handshaker;
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof FullHttpRequest) {
|
||||
handleHttpRequest(ctx, (FullHttpRequest) msg);
|
||||
} else if (msg instanceof WebSocketFrame) {
|
||||
|
@ -21,7 +21,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
|
||||
public class LocalEchoClientHandler extends SimpleChannelInboundHandler<Object> {
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
// Print as received
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
public class LocalEchoServerHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
// Write back as received
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -56,13 +56,13 @@ public class ObjectEchoClientHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
// Echo back the received object to the server.
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,14 @@ public class ObjectEchoServerHandler extends ChannelInboundHandlerAdapter {
|
||||
ObjectEchoServerHandler.class.getName());
|
||||
|
||||
@Override
|
||||
public void messageReceived(
|
||||
public void channelRead(
|
||||
ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
// Echo back the received object to the client.
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class HexDumpProxyBackendHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
inboundChannel.write(msg).flush().addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
|
@ -63,7 +63,7 @@ public class HexDumpProxyFrontendHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (outboundChannel.isActive()) {
|
||||
outboundChannel.write(msg).flush().addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
|
@ -23,7 +23,7 @@ import io.netty.util.CharsetUtil;
|
||||
public class QuoteOfTheMomentClientHandler extends SimpleChannelInboundHandler<DatagramPacket> {
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
|
||||
String response = msg.content().toString(CharsetUtil.UTF_8);
|
||||
if (response.startsWith("QOTM: ")) {
|
||||
System.out.println("Quote of the Moment: " + response.substring(6));
|
||||
|
@ -44,7 +44,7 @@ public class QuoteOfTheMomentServerHandler extends SimpleChannelInboundHandler<D
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception {
|
||||
System.err.println(packet);
|
||||
if ("QOTM?".equals(packet.content().toString(CharsetUtil.UTF_8))) {
|
||||
ctx.write(new DatagramPacket(
|
||||
|
@ -26,7 +26,7 @@ public class RxtxClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
if ("OK".equals(msg)) {
|
||||
System.out.println("Serial port responded to AT");
|
||||
} else {
|
||||
|
@ -55,12 +55,12 @@ public class SctpEchoClientHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,12 @@ public class SctpEchoServerHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class SecureChatClientHandler extends SimpleChannelInboundHandler<String>
|
||||
SecureChatClientHandler.class.getName());
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
System.err.println(msg);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class SecureChatServerHandler extends SimpleChannelInboundHandler<String>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
// Send the received message to all channels but the current one.
|
||||
for (Channel c: channels) {
|
||||
if (c != ctx.channel()) {
|
||||
|
@ -41,7 +41,7 @@ public final class RelayHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (relayChannel.isActive()) {
|
||||
relayChannel.write(msg).flush();
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ public final class SocksServerConnectHandler extends SimpleChannelInboundHandler
|
||||
private final Bootstrap b = new Bootstrap();
|
||||
|
||||
@Override
|
||||
public void messageReceived0(final ChannelHandlerContext ctx, final SocksCmdRequest request) throws Exception {
|
||||
public void channelRead0(final ChannelHandlerContext ctx, final SocksCmdRequest request) throws Exception {
|
||||
CallbackNotifier cb = new CallbackNotifier() {
|
||||
@Override
|
||||
public void onSuccess(final ChannelHandlerContext outboundCtx) {
|
||||
|
@ -37,7 +37,7 @@ public final class SocksServerHandler extends SimpleChannelInboundHandler<SocksR
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception {
|
||||
switch (socksRequest.requestType()) {
|
||||
case INIT: {
|
||||
// auth support example
|
||||
@ -56,7 +56,7 @@ public final class SocksServerHandler extends SimpleChannelInboundHandler<SocksR
|
||||
if (req.cmdType() == SocksCmdType.CONNECT) {
|
||||
ctx.pipeline().addLast(SocksServerConnectHandler.getName(), new SocksServerConnectHandler());
|
||||
ctx.pipeline().remove(this);
|
||||
ctx.fireMessageReceived(socksRequest);
|
||||
ctx.fireChannelRead(socksRequest);
|
||||
} else {
|
||||
ctx.close();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class TelnetClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
private static final Logger logger = Logger.getLogger(TelnetClientHandler.class.getName());
|
||||
|
||||
@Override
|
||||
protected void messageReceived0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
System.err.println(msg);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class TelnetServerHandler extends SimpleChannelInboundHandler<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, String request) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, String request) throws Exception {
|
||||
|
||||
// Generate and write a response.
|
||||
String response;
|
||||
|
@ -58,14 +58,14 @@ public class ByteEchoClientHandler extends SimpleChannelInboundHandler<ByteBuf>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||
meter.mark(msg.readableBytes());
|
||||
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,12 @@ public class ByteEchoServerHandler extends ChannelInboundHandlerAdapter {
|
||||
private static final Logger log = Logger.getLogger(ByteEchoServerHandler.class.getName());
|
||||
|
||||
@Override
|
||||
public void messageReceived(final ChannelHandlerContext ctx, Object msg) {
|
||||
public void channelRead(final ChannelHandlerContext ctx, Object msg) {
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -65,14 +65,14 @@ public class MsgEchoClientHandler extends SimpleChannelInboundHandler<UdtMessage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, UdtMessage msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, UdtMessage msg) throws Exception {
|
||||
meter.mark(msg.content().readableBytes());
|
||||
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
}
|
||||
|
@ -44,12 +44,12 @@ public class MsgEchoServerHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
}
|
||||
|
@ -66,14 +66,14 @@ public class MsgEchoPeerHandler extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, UdtMessage message) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, UdtMessage message) throws Exception {
|
||||
meter.mark(message.content().readableBytes());
|
||||
|
||||
ctx.write(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
}
|
||||
|
@ -60,14 +60,14 @@ public class ByteEchoPeerHandler extends SimpleChannelInboundHandler<ByteBuf> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
|
||||
meter.mark(buf.readableBytes());
|
||||
|
||||
ctx.write(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class UptimeClientHandler extends SimpleChannelInboundHandler<Object> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
// Discard received data
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class WorldClockClientHandler extends SimpleChannelInboundHandler<LocalTi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, LocalTimes times) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, LocalTimes times) throws Exception {
|
||||
answer.add(times);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class WorldClockServerHandler extends SimpleChannelInboundHandler<Locatio
|
||||
WorldClockServerHandler.class.getName());
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Locations locations) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Locations locations) throws Exception {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
LocalTimes.Builder builder = LocalTimes.newBuilder();
|
||||
@ -61,7 +61,7 @@ public class WorldClockServerHandler extends SimpleChannelInboundHandler<Locatio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -291,9 +291,9 @@ public class LoggingHandler extends ChannelDuplexHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
logMessage(ctx, "RECEIVED", msg);
|
||||
ctx.fireMessageReceived(msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -540,7 +540,7 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
||||
List<Object> messageList = new ArrayList<Object>();
|
||||
decode(ctx, internalBuffer(), messageList);
|
||||
for (int i = 0; i < messageList.size(); i++) {
|
||||
ctx.fireMessageReceived(messageList.get(i));
|
||||
ctx.fireChannelRead(messageList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -808,6 +808,7 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
||||
return packetLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws SSLException {
|
||||
int packetLength = this.packetLength;
|
||||
if (packetLength == 0) {
|
||||
|
@ -247,10 +247,10 @@ public class IdleStateHandler extends ChannelDuplexHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
lastReadTime = System.currentTimeMillis();
|
||||
firstReaderIdleEvent = firstAllIdleEvent = true;
|
||||
ctx.fireMessageReceived(msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,9 +144,9 @@ public class ReadTimeoutHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
lastReadTime = System.currentTimeMillis();
|
||||
ctx.fireMessageReceived(msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
private void initialize(ChannelHandlerContext ctx) {
|
||||
|
@ -208,7 +208,7 @@ public abstract class AbstractTrafficShapingHandler extends ChannelDuplexHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final ChannelHandlerContext ctx, final Object msg) throws Exception {
|
||||
public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
|
||||
ByteBuf buf = (ByteBuf) msg;
|
||||
long size = buf.readableBytes();
|
||||
long curtime = System.currentTimeMillis();
|
||||
@ -217,7 +217,7 @@ public abstract class AbstractTrafficShapingHandler extends ChannelDuplexHandler
|
||||
trafficCounter.bytesRecvFlowControl(size);
|
||||
if (readLimit == 0) {
|
||||
// no action
|
||||
ctx.fireMessageReceived(msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -248,7 +248,7 @@ public abstract class AbstractTrafficShapingHandler extends ChannelDuplexHandler
|
||||
Runnable bufferUpdateTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ctx.fireMessageReceived(msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
};
|
||||
ctx.executor().schedule(bufferUpdateTask, wait, TimeUnit.MILLISECONDS);
|
||||
@ -256,7 +256,7 @@ public abstract class AbstractTrafficShapingHandler extends ChannelDuplexHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.fireMessageReceived(msg);
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -149,7 +149,7 @@ public class SctpEchoTest extends AbstractSctpTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
byte[] actual = new byte[in.readableBytes()];
|
||||
in.readBytes(actual);
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
|
||||
|
||||
sb.handler(new SimpleChannelInboundHandler<Object>() {
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
// Nothing will be sent.
|
||||
}
|
||||
});
|
||||
@ -97,7 +97,7 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
|
||||
private volatile boolean fail;
|
||||
|
||||
@Override
|
||||
protected void messageReceived0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
|
||||
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
|
||||
if (done) {
|
||||
fail = true;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
|
||||
|
||||
sb.handler(new SimpleChannelInboundHandler<DatagramPacket>() {
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
|
||||
assertEquals(1, msg.content().readInt());
|
||||
latch.countDown();
|
||||
}
|
||||
@ -48,7 +48,7 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
|
||||
|
||||
cb.handler(new SimpleChannelInboundHandler<Object>() {
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msgs) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msgs) throws Exception {
|
||||
// Nothing will be sent.
|
||||
}
|
||||
});
|
||||
|
@ -95,7 +95,7 @@ public class SocketBufReleaseTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
// discard
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ public class SocketEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
byte[] actual = new byte[in.readableBytes()];
|
||||
in.readBytes(actual);
|
||||
|
||||
@ -216,7 +216,7 @@ public class SocketEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class SocketFileRegionTest extends AbstractSocketTest {
|
||||
|
||||
ChannelInboundHandler ch = new SimpleChannelInboundHandler<Object>() {
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,7 +131,7 @@ public class SocketFileRegionTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
byte[] actual = new byte[in.readableBytes()];
|
||||
in.readBytes(actual);
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class SocketFixedLengthEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||
assertEquals(1024, msg.readableBytes());
|
||||
|
||||
byte[] actual = new byte[msg.readableBytes()];
|
||||
@ -153,7 +153,7 @@ public class SocketFixedLengthEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class SocketGatheringWriteTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
counter += in.readableBytes();
|
||||
received.writeBytes(in);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import java.io.IOException;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SocketObjectEchoTest extends AbstractSocketTest {
|
||||
|
||||
@ -145,7 +145,7 @@ public class SocketObjectEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
assertEquals(data[counter], msg);
|
||||
|
||||
if (channel.parent() != null) {
|
||||
@ -156,7 +156,7 @@ public class SocketObjectEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class SocketShutdownOutputByPeerTest extends AbstractServerSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||
queue.offer(msg.readByte());
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class SocketShutdownOutputBySelfTest extends AbstractClientSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
|
||||
queue.offer(msg.readByte());
|
||||
}
|
||||
}
|
||||
|
@ -233,12 +233,12 @@ public class SocketSpdyEchoTest extends AbstractSocketTest {
|
||||
final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.write(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ public class SocketSpdyEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
byte[] actual = new byte[in.readableBytes()];
|
||||
in.readBytes(actual);
|
||||
|
||||
|
@ -180,7 +180,7 @@ public class SocketSslEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
|
||||
byte[] actual = new byte[in.readableBytes()];
|
||||
in.readBytes(actual);
|
||||
|
||||
@ -197,7 +197,7 @@ public class SocketSslEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ public class SocketStartTlsTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
if ("StartTlsResponse".equals(msg)) {
|
||||
ctx.pipeline().addAfter("logger", "ssl", sslHandler);
|
||||
handshakeFuture = sslHandler.handshakeFuture();
|
||||
@ -201,7 +201,7 @@ public class SocketStartTlsTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
if ("StartTlsRequest".equals(msg)) {
|
||||
ctx.pipeline().addAfter("logger", "ssl", sslHandler);
|
||||
ctx.writeAndFlush("StartTlsResponse\n");
|
||||
|
@ -146,7 +146,7 @@ public class SocketStringEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
assertEquals(data[counter], msg);
|
||||
|
||||
if (channel.parent() != null) {
|
||||
@ -158,7 +158,7 @@ public class SocketStringEchoTest extends AbstractSocketTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ public class UDTClientServerConnectionTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
log.info("Client received: " + msg);
|
||||
}
|
||||
}
|
||||
@ -320,7 +320,7 @@ public class UDTClientServerConnectionTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
log.info("Server received: " + msg);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class EchoByteHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ByteBuf buf = (ByteBuf) msg;
|
||||
if (meter != null) {
|
||||
meter.mark(buf.readableBytes());
|
||||
|
@ -67,7 +67,7 @@ public class EchoMessageHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
UdtMessage udtMsg = (UdtMessage) msg;
|
||||
if (meter != null) {
|
||||
meter.mark(udtMsg.content().readableBytes());
|
||||
|
@ -226,7 +226,7 @@ public final class ServerBootstrap extends AbstractBootstrap<ServerBootstrap, Se
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
Channel child = (Channel) msg;
|
||||
|
||||
child.pipeline().addLast(childHandler);
|
||||
|
@ -653,7 +653,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
promise = outboundBuffer.currentPromise;
|
||||
}
|
||||
|
||||
MessageList<Object> messages = outboundBuffer.currentMessages;
|
||||
MessageList messages = outboundBuffer.currentMessages;
|
||||
|
||||
// Make sure the message list is not empty.
|
||||
if (messages == null) {
|
||||
|
@ -120,7 +120,7 @@ public interface ChannelConfig {
|
||||
|
||||
/**
|
||||
* Returns the maximum number of messages in a {@link MessageList} of
|
||||
* a {@link ChannelInboundHandler#messageReceived(ChannelHandlerContext, MessageList) messageReceived()} event.
|
||||
* a {@link ChannelInboundHandler#channelRead(ChannelHandlerContext, Object) channelRead()} event.
|
||||
* If this value is greater than 1, an event loop might attempt to read multiple times to fill multiple messages
|
||||
* into the {@link MessageList}.
|
||||
*/
|
||||
@ -128,7 +128,7 @@ public interface ChannelConfig {
|
||||
|
||||
/**
|
||||
* Sets the maximum number of messages in a {@link MessageList} of
|
||||
* a {@link ChannelInboundHandler#messageReceived(ChannelHandlerContext, MessageList) messageReceived()} event.
|
||||
* a {@link ChannelInboundHandler#channelRead(ChannelHandlerContext, Object) channelRead()} event.
|
||||
* If this value is greater than 1, an event loop might attempt to read multiple times to fill multiple messages
|
||||
* into the {@link MessageList}.
|
||||
*/
|
||||
|
@ -95,7 +95,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* <pre>
|
||||
* // BAD - NEVER DO THIS
|
||||
* {@code @Override}
|
||||
* public void messageReceived({@link ChannelHandlerContext} ctx, GoodByeMessage msg) {
|
||||
* public void channelRead({@link ChannelHandlerContext} ctx, GoodByeMessage msg) {
|
||||
* {@link ChannelFuture} future = ctx.channel().close();
|
||||
* future.awaitUninterruptibly();
|
||||
* // Perform post-closure operation
|
||||
@ -104,7 +104,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*
|
||||
* // GOOD
|
||||
* {@code @Override}
|
||||
* public void messageReceived({@link ChannelHandlerContext} ctx, GoodByeMessage msg) {
|
||||
* public void channelRead({@link ChannelHandlerContext} ctx, GoodByeMessage msg) {
|
||||
* {@link ChannelFuture} future = ctx.channel().close();
|
||||
* future.addListener(new {@link ChannelFutureListener}() {
|
||||
* public void operationComplete({@link ChannelFuture} future) {
|
||||
|
@ -69,7 +69,7 @@ import java.lang.annotation.Target;
|
||||
* <b>private boolean loggedIn;</b>
|
||||
*
|
||||
* {@code @Override}
|
||||
* public void messageReceived({@link ChannelHandlerContext} ctx, Message message) {
|
||||
* public void channelRead({@link ChannelHandlerContext} ctx, Message message) {
|
||||
* {@link Channel} ch = e.getChannel();
|
||||
* if (message instanceof LoginMessage) {
|
||||
* authenticate((LoginMessage) message);
|
||||
@ -120,11 +120,11 @@ import java.lang.annotation.Target;
|
||||
* // This handler will receive a sequence of increasing integers starting
|
||||
* // from 1.
|
||||
* {@code @Override}
|
||||
* public void messageReceived({@link ChannelHandlerContext} ctx, {@link Integer} integer) {
|
||||
* public void channelRead({@link ChannelHandlerContext} ctx, {@link Integer} integer) {
|
||||
* {@link Attribute}<{@link Boolean}> attr = ctx.getAttr(auth);
|
||||
*
|
||||
* {@code @Override}
|
||||
* public void messageReceived({@link ChannelHandlerContext} ctx, Message message) {
|
||||
* public void channelRead({@link ChannelHandlerContext} ctx, Message message) {
|
||||
* {@link Channel} ch = ctx.channel();
|
||||
* if (message instanceof LoginMessage) {
|
||||
* authenticate((LoginMessage) o);
|
||||
|
@ -88,7 +88,7 @@ import java.nio.channels.Channels;
|
||||
* // This handler will receive a sequence of increasing integers starting
|
||||
* // from 1.
|
||||
* {@code @Override}
|
||||
* public void messageReceived({@link ChannelHandlerContext} ctx, {@link Integer} integer) {
|
||||
* public void channelRead({@link ChannelHandlerContext} ctx, {@link Integer} integer) {
|
||||
* {@link Attribute}<{@link Integer}> attr = ctx.getAttr(counter);
|
||||
* Integer a = ctx.getAttr(counter).get();
|
||||
*
|
||||
@ -176,13 +176,10 @@ public interface ChannelHandlerContext
|
||||
ChannelHandlerContext fireUserEventTriggered(Object event);
|
||||
|
||||
@Override
|
||||
ChannelHandlerContext fireMessageReceived(Object msg);
|
||||
ChannelHandlerContext fireChannelRead(Object msg);
|
||||
|
||||
@Override
|
||||
ChannelHandlerContext fireMessageReceivedLast();
|
||||
|
||||
@Override
|
||||
ChannelHandlerContext fireChannelReadSuspended();
|
||||
ChannelHandlerContext fireChannelReadComplete();
|
||||
|
||||
@Override
|
||||
ChannelHandlerContext fireChannelWritabilityChanged();
|
||||
|
@ -43,20 +43,17 @@ public interface ChannelInboundHandler extends ChannelHandler {
|
||||
void channelInactive(ChannelHandlerContext ctx) throws Exception;
|
||||
|
||||
/**
|
||||
* Invoked when a {@link ChannelHandlerContext#read()} is finished and the inbound buffer of this handler will not
|
||||
* be updated until another {@link ChannelHandlerContext#read()} request is issued.
|
||||
* Invoked when the current {@link Channel} has read a message from the peer.
|
||||
*/
|
||||
void channelReadSuspended(ChannelHandlerContext ctx) throws Exception;
|
||||
void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception;
|
||||
|
||||
/**
|
||||
* The inbound buffer of the {@link ChannelHandlerContext} was updated with new data.
|
||||
* This means something may be ready to get processed by the actual {@link ChannelInboundHandler}
|
||||
* implementation. It's up to the implementation to consume it or keep it in the buffer
|
||||
* to wait for more data and consume it later.
|
||||
* Invoked when the last message read by the current read operation has been consumed by
|
||||
* {@link #channelRead(ChannelHandlerContext, Object)}. If {@link ChannelOption#AUTO_READ} is off, no further
|
||||
* attempt to read an inbound data from the current {@link Channel} will be made until
|
||||
* {@link ChannelHandlerContext#read()} is called.
|
||||
*/
|
||||
void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception;
|
||||
|
||||
void messageReceivedLast(ChannelHandlerContext ctx) throws Exception;
|
||||
void channelReadComplete(ChannelHandlerContext ctx) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets called if an user event was triggered.
|
||||
|
@ -24,7 +24,7 @@ package io.netty.channel;
|
||||
* {@link ChannelPipeline}. Sub-classes may override a method implementation to change this.
|
||||
* </p>
|
||||
* <p>
|
||||
* Be aware that messages are not released after the {@link #messageReceived(ChannelHandlerContext, Object)}
|
||||
* Be aware that messages are not released after the {@link #channelRead(ChannelHandlerContext, Object)}
|
||||
* method returns automatically. If you are looking for a {@link ChannelInboundHandler} implementation that
|
||||
* releases the received messages automatically, please see {@link SimpleChannelInboundHandler}.
|
||||
* </p>
|
||||
@ -74,31 +74,21 @@ public class ChannelInboundHandlerAdapter extends ChannelHandlerAdapter implemen
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelInactive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link ChannelHandlerContext#fireChannelReadSuspended()} to forward
|
||||
* Calls {@link ChannelHandlerContext#fireChannelRead(Object)} to forward
|
||||
* to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
|
||||
*
|
||||
* Sub-classes may override this method to change behavior.
|
||||
*/
|
||||
@Override
|
||||
public void channelReadSuspended(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelReadSuspended();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link ChannelHandlerContext#fireMessageReceived(Object)} to forward
|
||||
* to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
|
||||
*
|
||||
* Sub-classes may override this method to change behavior.
|
||||
*/
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.fireMessageReceived(msg);
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceivedLast(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireMessageReceivedLast();
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelReadComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,21 +76,15 @@ interface ChannelInboundInvoker {
|
||||
ChannelInboundInvoker fireUserEventTriggered(Object event);
|
||||
|
||||
/**
|
||||
* A {@link Channel} received bytes which are now ready to read from its inbound buffer.
|
||||
* A {@link Channel} received a message.
|
||||
*
|
||||
* This will result in having the {@link ChannelInboundHandler#messageReceived(ChannelHandlerContext, Object)}
|
||||
* This will result in having the {@link ChannelInboundHandler#channelRead(ChannelHandlerContext, Object)}
|
||||
* method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
||||
* {@link Channel}.
|
||||
*/
|
||||
ChannelInboundInvoker fireMessageReceived(Object msg);
|
||||
ChannelInboundInvoker fireChannelRead(Object msg);
|
||||
|
||||
ChannelInboundInvoker fireMessageReceivedLast();
|
||||
|
||||
/**
|
||||
* Triggers an {@link ChannelInboundHandler#channelReadSuspended(ChannelHandlerContext) channelReadSuspended}
|
||||
* event to the next {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
|
||||
*/
|
||||
ChannelInboundInvoker fireChannelReadSuspended();
|
||||
ChannelInboundInvoker fireChannelReadComplete();
|
||||
|
||||
/**
|
||||
* Triggers an {@link ChannelInboundHandler#channelWritabilityChanged(ChannelHandlerContext)}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user