public abstract static class ProtocolNegotiators.AbstractBufferingHandler
extends io.netty.channel.ChannelDuplexHandler
writeBufferedAndRemove(ChannelHandlerContext) or
fail(ChannelHandlerContext, Throwable) is called. This handler allows us to
write to a Channel before we are allowed to write to it officially
i.e. before it's active or the TLS Handshake is complete.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractBufferingHandler(io.netty.channel.ChannelHandler... handlers) |
| Modifier and Type | Method and Description |
|---|---|
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx)
If this channel becomes inactive, then notify all buffered writes that we failed.
|
void |
channelRegistered(io.netty.channel.ChannelHandlerContext ctx)
When this channel is registered, we will add all the ChannelHandlers passed into our
constructor to the pipeline.
|
void |
close(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise future)
If we are still performing protocol negotiation, then this will propagate failures to all
buffered writes.
|
void |
connect(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise)
Do not rely on channel handlers to propagate exceptions to us.
|
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
If we encounter an exception, then notify all buffered writes that we failed.
|
protected void |
fail(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
Propagate failures to all buffered writes.
|
void |
flush(io.netty.channel.ChannelHandlerContext ctx)
Calls to this method will not trigger an immediate flush.
|
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
Buffers the write until either
writeBufferedAndRemove(ChannelHandlerContext) is
called, or we have somehow failed. |
protected void |
writeBufferedAndRemove(io.netty.channel.ChannelHandlerContext ctx) |
bind, deregister, disconnect, readchannelActive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharableprotected AbstractBufferingHandler(io.netty.channel.ChannelHandler... handlers)
handlers - the ChannelHandlers are added to the pipeline on channelRegistered and
before this handler.public void channelRegistered(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelRegistered in interface io.netty.channel.ChannelInboundHandlerchannelRegistered in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void connect(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise)
throws Exception
NettyClientHandler is an example of a class that does not propagate exceptions.
Add a listener to the connect future directly and do appropriate error handling.connect in interface io.netty.channel.ChannelOutboundHandlerconnect in class io.netty.channel.ChannelDuplexHandlerExceptionpublic void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
throws Exception
exceptionCaught in interface io.netty.channel.ChannelHandlerexceptionCaught in interface io.netty.channel.ChannelInboundHandlerexceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelInactive in interface io.netty.channel.ChannelInboundHandlerchannelInactive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
throws Exception
writeBufferedAndRemove(ChannelHandlerContext) is
called, or we have somehow failed. If we have already failed in the past, then the write
will fail immediately.write in interface io.netty.channel.ChannelOutboundHandlerwrite in class io.netty.channel.ChannelDuplexHandlerExceptionpublic void flush(io.netty.channel.ChannelHandlerContext ctx)
writeBufferedAndRemove(ChannelHandlerContext).flush in interface io.netty.channel.ChannelOutboundHandlerflush in class io.netty.channel.ChannelDuplexHandlerpublic void close(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise future)
throws Exception
close in interface io.netty.channel.ChannelOutboundHandlerclose in class io.netty.channel.ChannelDuplexHandlerExceptionprotected final void fail(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
protected final void writeBufferedAndRemove(io.netty.channel.ChannelHandlerContext ctx)