Top Description Fields Constructors Methods
io.netty.handler.codec.protobuf

public Class ProtobufVarint32FrameDecoder

extends ByteToMessageDecoder
Class Inheritance
Imports
com.google.protobuf.CodedInputStream, com.google.protobuf.nano.CodedInputByteBufferNano, io.netty.buffer.ByteBuf, io.netty.channel.ChannelHandlerContext, io.netty.handler.codec.ByteToMessageDecoder, .CorruptedFrameException, java.util.List

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

Field Summary

Inherited from io.netty.handler.codec.ByteToMessageDecoder:
COMPOSITE_CUMULATORMERGE_CUMULATOR

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
decode(ChannelHandlerContext ctx, ByteBuf
the ByteBuf from which to read data
in
,
List<Object>
the List to which decoded messages should be added
out
)

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Decode the from one ByteBuf to an other.
private static int

Returns:

decoded int if buffers readerIndex has been forwarded else nonsense value
readRawVarint32
(ByteBuf buffer)

Reads variable length 32bit int from buffer

Inherited from io.netty.handler.codec.ByteToMessageDecoder:
actualReadableBytescallDecodechannelInactivechannelReadchannelReadCompletedecodeLastdiscardSomeReadByteshandlerRemovedhandlerRemoved0internalBufferisSingleDecodesetCumulatorsetDiscardAfterReadssetSingleDecodeuserEventTriggered

Constructor Detail

ProtobufVarint32FrameDecoderback to summary
public ProtobufVarint32FrameDecoder()

Method Detail

decodeback to summary
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Doc from io.netty.handler.codec.ByteToMessageDecoder.decode.

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.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

in:ByteBuf

the ByteBuf from which to read data

out:List<Object>

the List to which decoded messages should be added

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
readRawVarint32back to summary
private static int readRawVarint32(ByteBuf buffer)

Reads variable length 32bit int from buffer

Returns:int

decoded int if buffers readerIndex has been forwarded else nonsense value