@UnstableApi public final class Http2MultiplexCodec extends ChannelDuplexHandler
When a new stream is created, a new Channel
is created for it. Applications send and
receive Http2StreamFrame
s on the created channel. ByteBuf
s cannot be processed by the channel;
all writes that reach the head of the pipeline must be an instance of Http2StreamFrame
. Writes that reach
the head of the pipeline are processed directly by this handler and cannot be intercepted.
The child channel will be notified of user events that impact the stream, such as Http2GoAwayFrame
and Http2ResetFrame
, as soon as they occur. Although Http2GoAwayFrame
and Http2ResetFrame
signify that the remote is ignoring further
communication, closing of the channel is delayed until any inbound queue is drained with Channel.read()
, which follows the default behavior of channels in Netty. Applications are
free to close the channel in response to such events if they don't have use for any queued
messages.
Outbound streams are supported via the Http2StreamChannelBootstrap
.
ChannelConfig.setMaxMessagesPerRead(int)
and ChannelConfig.setAutoRead(boolean)
are supported.
ChannelHandler.Sharable
Constructor and Description |
---|
Http2MultiplexCodec(boolean server,
Http2StreamChannelBootstrap bootstrap)
Construct a new handler whose child channels run in a different event loop.
|
Modifier and Type | Method and Description |
---|---|
void |
channelRead(ChannelHandlerContext ctx,
Object msg)
Calls
ChannelHandlerContext.fireChannelRead(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline . |
void |
channelReadComplete(ChannelHandlerContext ctx)
Notifies any child streams of the read completion.
|
void |
exceptionCaught(ChannelHandlerContext ctx,
Throwable cause)
Calls
ChannelHandlerContext.fireExceptionCaught(Throwable) to forward
to the next ChannelHandler in the ChannelPipeline . |
void |
flush(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.flush() to forward
to the next ChannelOutboundHandler in the ChannelPipeline . |
void |
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
void |
userEventTriggered(ChannelHandlerContext ctx,
Object evt)
Calls
ChannelHandlerContext.fireUserEventTriggered(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline . |
bind, close, connect, deregister, disconnect, read, write
channelActive, channelInactive, channelRegistered, channelUnregistered, channelWritabilityChanged
ensureNotSharable, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerRemoved
public Http2MultiplexCodec(boolean server, Http2StreamChannelBootstrap bootstrap)
server
- true
this is a serverbootstrap
- bootstrap used to instantiate child channels for remotely-created streams.public void handlerAdded(ChannelHandlerContext ctx)
ChannelHandlerAdapter
handlerAdded
in interface ChannelHandler
handlerAdded
in class ChannelHandlerAdapter
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireExceptionCaught(Throwable)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.exceptionCaught
in interface ChannelHandler
exceptionCaught
in interface ChannelInboundHandler
exceptionCaught
in class ChannelInboundHandlerAdapter
public void flush(ChannelHandlerContext ctx)
ChannelDuplexHandler
ChannelHandlerContext.flush()
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.flush
in interface ChannelOutboundHandler
flush
in class ChannelDuplexHandler
ctx
- the ChannelHandlerContext
for which the flush operation is madepublic void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelRead(Object)
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelRead
in interface ChannelInboundHandler
channelRead
in class ChannelInboundHandlerAdapter
Exception
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireUserEventTriggered(Object)
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.userEventTriggered
in interface ChannelInboundHandler
userEventTriggered
in class ChannelInboundHandlerAdapter
Exception
public void channelReadComplete(ChannelHandlerContext ctx)
channelReadComplete
in interface ChannelInboundHandler
channelReadComplete
in class ChannelInboundHandlerAdapter
Copyright © 2008–2017 The Netty Project. All rights reserved.