Class 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 specified ChunkedInput into a series of sortable MessageChunks, allowing the receiver to reassemble the ByteBuf in correct order. Useful for protocols that does provide message ordering (like UDP or drasyl).
      ChannelPipeline p = ...;
      ...
      p.addLast("encoder", new MessageChunkEncoder());
      p.addLast("chunked_write", new ChunkedWriteHandler);
      p.addLast("decoder", new MessageChunkDecoder());
      p.addLast("buffer", new MessageChunksBuffer(65536, 5000));
      p.addLast("aggregator", new ChunkedMessageAggregator(65536));
      ...
      p.addLast("handler", new MyReassembledMessageHandler());
      
    • Constructor Detail

      • ChunkedMessageInput

        public ChunkedMessageInput​(io.netty.handler.stream.ChunkedInput<io.netty.buffer.ByteBuf> input)
    • Method Detail

      • isEndOfInput

        public boolean isEndOfInput()
                             throws Exception
        Specified by:
        isEndOfInput in interface io.netty.handler.stream.ChunkedInput<MessageChunk>
        Throws:
        Exception
      • close

        public void close()
                   throws Exception
        Specified by:
        close in interface io.netty.handler.stream.ChunkedInput<MessageChunk>
        Throws:
        Exception
      • readChunk

        public MessageChunk readChunk​(io.netty.channel.ChannelHandlerContext ctx)
                               throws Exception
        Specified by:
        readChunk in interface io.netty.handler.stream.ChunkedInput<MessageChunk>
        Throws:
        Exception
      • readChunk

        public MessageChunk readChunk​(io.netty.buffer.ByteBufAllocator allocator)
                               throws Exception
        Specified by:
        readChunk in interface io.netty.handler.stream.ChunkedInput<MessageChunk>
        Throws:
        Exception
      • length

        public long length()
        Specified by:
        length in interface io.netty.handler.stream.ChunkedInput<MessageChunk>
      • progress

        public long progress()
        Specified by:
        progress in interface io.netty.handler.stream.ChunkedInput<MessageChunk>