public final class Http2MultiplexCodec extends ChannelDuplexHandler
Http2ServerUpgradeCodec; the necessary HTTP-to-HTTP/2 conversion is performed automatically.
This API is very immature. The Http2Connection-based API is currently preferred over this API. This API is targeted to eventually replace or reduce the need for the Http2Connection-based API.
This handler notifies the pipeline of channel events, such as Http2GoAwayFrame. It
is also capable of writing such messages. Directly writing Http2StreamFrames for this
handler is unsupported.
When a new stream is created, a new Channel is created for it. Applications send and
receive Http2StreamFrames on the created channel. The Http2StreamFrame.stream() is
expected to be null, but the channel can use the field for its own bookkeeping. ByteBufs 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.
ChannelConfig.setMaxMessagesPerRead(int) and ChannelConfig.setAutoRead(boolean) are supported.
ChannelHandler.Sharable| Constructor and Description |
|---|
Http2MultiplexCodec(boolean server,
ChannelHandler streamHandler)
Construct a new handler whose child channels run in the same event loop as this handler.
|
Http2MultiplexCodec(boolean server,
ChannelHandler streamHandler,
EventLoopGroup streamGroup)
Construct a new handler whose child channels run in a different event loop.
|
| Modifier and Type | Method and Description |
|---|---|
void |
channelReadComplete(ChannelHandlerContext ctx)
Notifies any child streams of the read completion.
|
void |
handlerAdded(ChannelHandlerContext ctx)
Save context and load any dependencies.
|
void |
handlerRemoved(ChannelHandlerContext ctx)
Clean up any dependencies.
|
void |
userEventTriggered(ChannelHandlerContext ctx,
Object evt)
Handles the cleartext HTTP upgrade event.
|
void |
write(ChannelHandlerContext ctx,
Object msg,
ChannelPromise promise)
Processes all
Http2Frames. |
bind, close, connect, deregister, disconnect, flush, readchannelActive, channelInactive, channelRead, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtisSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexceptionCaughtpublic Http2MultiplexCodec(boolean server,
ChannelHandler streamHandler)
server - true this is a serverstreamHandler - the handler added to channels for remotely-created streams. It must be
ChannelHandler.Sharable.public Http2MultiplexCodec(boolean server,
ChannelHandler streamHandler,
EventLoopGroup streamGroup)
server - true this is a serverstreamHandler - the handler added to channels for remotely-created streams. It must be
ChannelHandler.Sharable.streamGroup - event loop for registering child channelspublic void handlerAdded(ChannelHandlerContext ctx) throws Exception
handlerAdded in interface ChannelHandlerhandlerAdded in class ChannelHandlerAdapterExceptionpublic void handlerRemoved(ChannelHandlerContext ctx) throws Exception
handlerRemoved in interface ChannelHandlerhandlerRemoved in class ChannelHandlerAdapterExceptionpublic void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
userEventTriggered in interface ChannelInboundHandleruserEventTriggered in class ChannelInboundHandlerAdapterExceptionpublic void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
Http2Frames. Http2StreamFrames may only originate in child
streams.write in interface ChannelOutboundHandlerwrite in class ChannelDuplexHandlerctx - the ChannelHandlerContext for which the write operation is mademsg - the message to writepromise - the ChannelPromise to notify once the operation completesException - thrown if an error accourpublic void channelReadComplete(ChannelHandlerContext ctx)
channelReadComplete in interface ChannelInboundHandlerchannelReadComplete in class ChannelInboundHandlerAdapterCopyright © 2008–2016 The Netty Project. All rights reserved.