@UnstableApi public class Http2MultiplexCodec extends Http2FrameCodec
当创建新的流时,会为其创建一个新的Channel 。 应用程序在创建的频道上发送和接收Http2StreamFrame 。 ByteBuf s不能被通道处理; 所有到达管线头的写入操作都必须是Http2StreamFrame的一个实例。 到达管道头部的写入操作直接由该处理程序处理,不能被截取。
子通道会在发生影响流的用户事件时通知,例如Http2GoAwayFrame和Http2ResetFrame 。 尽管Http2GoAwayFrame和Http2ResetFrame表示远程设备忽略了进一步的通信,但通道的关闭会延迟,直到任何入站队列用Channel.read()排空 ,该排列遵循Netty中通道的默认行为。 如果应用程序没有用于任何排队消息,则应用程序可以自由关闭该通道以响应此类事件。 任何连接级别事件(如Http2SettingsFrame和Http2GoAwayFrame)都将在内部进行处理,并向下传播以供其他处理程序执行。
出站流通过Http2StreamChannelBootstrap支持。
支持ChannelConfig.setMaxMessagesPerRead(int)和ChannelConfig.setAutoRead(boolean) 。
Http2StreamFrame实现了ReferenceCounted接口,因为它们携带引用计数对象(例如ByteBuf s)。
多路复用编解码器在通过管道传播引用计数对象之前将调用ReferenceCounted.retain() ,因此应用程序处理程序需要在使用它之后释放这样的对象。
有关引用计数的更多信息,请参阅http://netty.io/wiki/reference-counted-objects.html
EventLoop,子频道就会激活。
因此,活动频道不会立即映射到活动的HTTP / 2流。
只有Http2HeadersFrame成功发送或接收后,频道才会映射到活动的HTTP / 2流。
如果无法打开新的HTTP / 2流(即由于超过最大活动流数量),子通道会收到指示原因的异常,并在此后立即关闭。
ChannelHandler可以自由地忽略通道的可写性,在这种情况下,过多的写入将被父通道缓冲。
重要的是要注意,只有Http2DataFrame s受到HTTP / 2流量控制。
ByteToMessageDecoder.CumulatorChannelHandler.SharableCOMPOSITE_CUMULATOR, MERGE_CUMULATOR| Modifier and Type | Method and Description |
|---|---|
void |
channelRead(ChannelHandlerContext ctx, java.lang.Object msg)
|
void |
channelReadComplete(ChannelHandlerContext ctx)
通知读取完成的任何子流。
|
void |
handlerAdded0(ChannelHandlerContext ctx) |
void |
handlerRemoved0(ChannelHandlerContext ctx)
在 ByteToMessageDecoder已从实际上下文中移除并且不再处理事件之后调用。
|
handlerAdded, isGracefulShutdownComplete, onConnectionError, onStreamError, userEventTriggered, writebind, channelActive, channelInactive, channelWritabilityChanged, close, closeStream, closeStreamLocal, closeStreamRemote, connect, connection, decode, decoder, deregister, disconnect, encoder, exceptionCaught, flush, frameWriter, goAway, gracefulShutdownTimeoutMillis, gracefulShutdownTimeoutMillis, handleServerHeaderDecodeSizeError, onError, onHttpClientUpgrade, onHttpServerUpgrade, read, resetStreamactualReadableBytes, callDecode, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecodechannelRegistered, channelUnregisteredensureNotSharable, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerRemovedpublic final void handlerAdded0(ChannelHandlerContext ctx) throws java.lang.Exception
java.lang.Exception
public final void handlerRemoved0(ChannelHandlerContext ctx) throws java.lang.Exception
ByteToMessageDecoder
ByteToMessageDecoder已从实际上下文中移除后调用,它不再处理事件。
handlerRemoved0在课堂上
Http2ConnectionHandler
java.lang.Exception
public final void channelReadComplete(ChannelHandlerContext ctx) throws java.lang.Exception
channelReadComplete在界面
ChannelInboundHandler
channelReadComplete在课堂上
Http2ConnectionHandler
java.lang.Exception
public final void channelRead(ChannelHandlerContext ctx, java.lang.Object msg) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelRead(Object)转发到ChannelPipeline中的下一个ChannelInboundHandler 。
子类可以重写此方法来更改行为。
channelRead在界面
ChannelInboundHandler
channelRead在课堂上
ByteToMessageDecoder
java.lang.Exception
Copyright © 2008–2018 The Netty Project. All rights reserved.