Class ProtobufVarint32FrameDecoder

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

    public class ProtobufVarint32FrameDecoder
    extends ByteToMessageDecoder
    A decoder that splits the received ByteBufs dynamically by the value of the Google Protocol Buffers Base 128 Varints integer length field in the message. For example:
     BEFORE DECODE (302 bytes)       AFTER DECODE (300 bytes)
     +--------+---------------+      +---------------+
     | Length | Protobuf Data |----->| Protobuf Data |
     | 0xAC02 |  (300 bytes)  |      |  (300 bytes)  |
     +--------+---------------+      +---------------+
     
    See Also:
    CodedInputStream, CodedInputByteBufferNano
    • Constructor Detail

      • ProtobufVarint32FrameDecoder

        public ProtobufVarint32FrameDecoder()
    • Method Detail

      • decode

        protected void decode​(io.netty.channel.ChannelHandlerContext ctx,
                              io.netty.buffer.ByteBuf in,
                              List<Object> out)
                       throws Exception
        Description copied from class: ByteToMessageDecoder
        Decode the from one ByteBuf to an other. This method will be called till either the input ByteBuf has nothing to read when return from this method or till nothing was read from the input ByteBuf.
        Specified by:
        decode in class ByteToMessageDecoder
        Parameters:
        ctx - the ChannelHandlerContext which this ByteToMessageDecoder belongs to
        in - the ByteBuf from which to read data
        out - the List to which decoded messages should be added
        Throws:
        Exception - is thrown if an error occurs