Package org.drasyl.handler.stream
Class ChunkedMessageInput
- java.lang.Object
-
- org.drasyl.handler.stream.ChunkedMessageInput
-
- All Implemented Interfaces:
io.netty.handler.stream.ChunkedInput<MessageChunk>
public class ChunkedMessageInput extends Object implements io.netty.handler.stream.ChunkedInput<MessageChunk>
Wraps each chunk of the specifiedChunkedInput
into a series of sortableMessageChunk
s, allowing the receiver to reassemble theByteBuf
in correct order. Useful for protocols that does provide message ordering (likeUDP
or drasyl).ChannelPipeline
p = ...; ... p.addLast("encoder", newMessageChunkEncoder
()); p.addLast("chunked_write", newChunkedWriteHandler
); p.addLast("decoder", newMessageChunkDecoder
()); p.addLast("buffer", newMessageChunksBuffer
(65536, 5000)); p.addLast("aggregator", newChunkedMessageAggregator
(65536)); ... p.addLast("handler", new MyReassembledMessageHandler());
-
-
Constructor Summary
Constructors Constructor Description ChunkedMessageInput(io.netty.handler.stream.ChunkedInput<io.netty.buffer.ByteBuf> input)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
isEndOfInput()
long
length()
long
progress()
MessageChunk
readChunk(io.netty.buffer.ByteBufAllocator allocator)
MessageChunk
readChunk(io.netty.channel.ChannelHandlerContext ctx)
-
-
-
Method Detail
-
isEndOfInput
public boolean isEndOfInput() throws Exception
- Specified by:
isEndOfInput
in interfaceio.netty.handler.stream.ChunkedInput<MessageChunk>
- Throws:
Exception
-
close
public void close() throws Exception
- Specified by:
close
in interfaceio.netty.handler.stream.ChunkedInput<MessageChunk>
- Throws:
Exception
-
readChunk
public MessageChunk readChunk(io.netty.channel.ChannelHandlerContext ctx) throws Exception
- Specified by:
readChunk
in interfaceio.netty.handler.stream.ChunkedInput<MessageChunk>
- Throws:
Exception
-
readChunk
public MessageChunk readChunk(io.netty.buffer.ByteBufAllocator allocator) throws Exception
- Specified by:
readChunk
in interfaceio.netty.handler.stream.ChunkedInput<MessageChunk>
- Throws:
Exception
-
length
public long length()
- Specified by:
length
in interfaceio.netty.handler.stream.ChunkedInput<MessageChunk>
-
progress
public long progress()
- Specified by:
progress
in interfaceio.netty.handler.stream.ChunkedInput<MessageChunk>
-
-