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 all
MessageChunks belonging to the same message have been collected, then
passes them in the correct order.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionMessageChunksBuffer(int maxContentLength, int allChunksTimeout, int maxChunks) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddecode(io.netty.channel.ChannelHandlerContext ctx, MessageChunk msg, List<Object> out) Methods inherited from class io.netty.handler.codec.MessageToMessageDecoder
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
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 of0deactivates 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 Details
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, MessageChunk msg, List<Object> out) throws Exception - Specified by:
decodein classio.netty.handler.codec.MessageToMessageDecoder<MessageChunk>- Throws:
Exception
-