@UnstableApi
public final class Http2MultiplexCodec
extends io.netty.channel.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.
| Constructor and Description |
|---|
Http2MultiplexCodec(boolean server,
io.netty.channel.ChannelHandler streamHandler)
Construct a new handler whose child channels run in the same event loop as this handler.
|
Http2MultiplexCodec(boolean server,
io.netty.channel.ChannelHandler streamHandler,
io.netty.channel.EventLoopGroup streamGroup)
Construct a new handler whose child channels run in a different event loop.
|
| Modifier and Type | Method and Description |
|---|---|
void |
channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
Notifies any child streams of the read completion.
|
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
void |
flush(io.netty.channel.ChannelHandlerContext ctx) |
void |
handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
Save context and load any dependencies.
|
void |
handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
Clean up any dependencies.
|
void |
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
Handles the cleartext HTTP upgrade event.
|
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
Processes all
Http2Frames. |
bind, close, connect, deregister, disconnect, readpublic Http2MultiplexCodec(boolean server,
io.netty.channel.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,
io.netty.channel.ChannelHandler streamHandler,
io.netty.channel.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(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
handlerAdded in interface io.netty.channel.ChannelHandlerhandlerAdded in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
handlerRemoved in interface io.netty.channel.ChannelHandlerhandlerRemoved in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
throws Exception
userEventTriggered in interface io.netty.channel.ChannelInboundHandleruserEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
exceptionCaught in interface io.netty.channel.ChannelHandlerexceptionCaught in interface io.netty.channel.ChannelInboundHandlerexceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapterpublic void flush(io.netty.channel.ChannelHandlerContext ctx)
flush in interface io.netty.channel.ChannelOutboundHandlerflush in class io.netty.channel.ChannelDuplexHandlerpublic void write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
Http2Frames. Http2StreamFrames may only originate in child
streams.write in interface io.netty.channel.ChannelOutboundHandlerwrite in class io.netty.channel.ChannelDuplexHandlerpublic void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
channelReadComplete in interface io.netty.channel.ChannelInboundHandlerchannelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapterCopyright © 2008–2016 The Netty Project. All rights reserved.