下面列出了io.netty.channel.ChannelHandlerContext#read ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HAProxyMessage) {
HAProxyMessage proxyMessage = (HAProxyMessage) msg;
if (proxyMessage.sourceAddress() != null && proxyMessage.sourcePort() != 0) {
InetSocketAddress remoteAddress = AddressUtils
.createUnresolved(proxyMessage.sourceAddress(), proxyMessage.sourcePort());
ctx.channel()
.attr(REMOTE_ADDRESS_FROM_PROXY_PROTOCOL)
.set(remoteAddress);
}
proxyMessage.release();
ctx.channel()
.pipeline()
.remove(this);
ctx.read();
} else {
super.channelRead(ctx, msg);
}
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) {
if (!handshakeDone) {
ctx.read(); /* continue consuming. */
}
ctx.fireChannelReadComplete();
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
// We might need keep reading the channel until the full message is aggregated.我们可能需要一直读取通道,直到聚合完整的消息。
//
// See https://github.com/netty/netty/issues/6583
if (currentMessage != null && !ctx.channel().config().isAutoRead()) {
ctx.read();
}
ctx.fireChannelReadComplete();
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
try {
ctx.flush();
} finally {
if (!autoRead) {
ctx.read();
}
}
}
@Override
public void read(ChannelHandlerContext ctx) throws Exception {
if (dequeue(ctx, 1) == 0) {
// It seems no messages were consumed. We need to read() some
// messages from upstream and once one arrives it need to be
// relayed to downstream to keep the flow going.
shouldConsume = true;
ctx.read();
}
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
channel = ctx.channel();
if (!autoRead) {
ctx.read();
}
}
private void doChannelActive(ChannelHandlerContext ctx) {
if (waitForSslHandshake) {
// Force a read to get the SSL handshake started, any application data that makes it past the SslHandler
// will be queued in the NettyChannelPublisher.
ctx.read();
} else if (subscriber != null) {
completeSubscriber();
}
}
@Override
public void handlerAdded(final ChannelHandlerContext ctx) throws Exception {
super.handlerAdded(ctx);
if (forceRead) {
// Force a read to get the SSL handshake started. We initialize pipeline before
// SslHandshakeCompletionEvent will complete, therefore, no data will be propagated before we finish
// initialization.
ctx.read();
}
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
if (!autoRead) {
ctx.read();
}
}
@Override
public void read(ChannelHandlerContext ctx) throws Exception {
ctx.read();
}
@Override
public void channelActive(ChannelHandlerContext ctx) {
ctx.read();
}
@Override
public void read(ChannelHandlerContext ctx) throws Exception {
ctx.read();
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
if (!autoRead) {
ctx.read();
}
}
@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void read(ChannelHandlerContext ctx) {
ctx.read();
}
@Override
public void read(ChannelHandlerContext ctx) throws Exception {
if (DEBUG_CALLS) Gdx.app.debug(TAG, "read");
ctx.read();
}
@Override
public void channelActive(ChannelHandlerContext ctx) {
ctx.read(); //consume handshake
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
bytesRead.addAndGet(msg.readableBytes());
// Because autoread is off, we call read to consume all data until we detect the close.
ctx.read();
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
if (!autoRead) {
ctx.read();
}
}
@Override
public void read(ChannelHandlerContext ctx) throws Exception {
ctx.read();
}
@Override
public void read(ChannelHandlerContext ctx) throws Exception {
ctx.read();
}