Package org.drasyl.handler.stream
Class MessageChunksBuffer
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.MessageToMessageDecoder<MessageChunk>
-
- org.drasyl.handler.stream.MessageChunksBuffer
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
public class MessageChunksBuffer extends io.netty.handler.codec.MessageToMessageDecoder<MessageChunk>
Buffers until allMessageChunk
s belonging to the same message have been collected, then passes them in the correct order.- See Also:
ChunkedMessageInput
-
-
Constructor Summary
Constructors Constructor Description MessageChunksBuffer(int maxContentLength, int allChunksTimeout, int maxChunks)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
decode(io.netty.channel.ChannelHandlerContext ctx, MessageChunk msg, List<Object> out)
-
Methods inherited from class io.netty.handler.codec.MessageToMessageDecoder
acceptInboundMessage, channelRead
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Constructor Detail
-
MessageChunksBuffer
public MessageChunksBuffer(int maxContentLength, int allChunksTimeout, int maxChunks)
Creates a new instance.- Parameters:
maxContentLength
- the maximum cumulative length of the aggregated message. If the length of the buffered content exceeds this value, a {@link TooLongFrameException)} will be thrown.allChunksTimeout
- time in milliseconds after receiving the first chunk to wait for remaining chunks. Upon timeout, received chunks will be discarded. A value of0
deactivates the timeout function.maxChunks
- maximum number of chunks to collect. If the more chunks are required to aggregate the message, all chunks will be discarded.
-
-
Method Detail
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, MessageChunk msg, List<Object> out) throws Exception
- Specified by:
decode
in classio.netty.handler.codec.MessageToMessageDecoder<MessageChunk>
- Throws:
Exception
-
-