@ChannelHandler.Sharable public class ProtobufVarint32LengthFieldPrepender extends MessageToByteEncoder<ByteBuf>
BEFORE DECODE (300 bytes) AFTER DECODE (302 bytes) +---------------+ +--------+---------------+ | Protobuf Data |-------------->| Length | Protobuf Data | | (300 bytes) | | 0xAC02 | (300 bytes) | +---------------+ +--------+---------------+*
CodedOutputStream
ChannelHandler.Sharable, ChannelHandler.Skip
Constructor and Description |
---|
ProtobufVarint32LengthFieldPrepender() |
Modifier and Type | Method and Description |
---|---|
protected void |
encode(ChannelHandlerContext ctx,
ByteBuf msg,
ByteBuf out)
Encode a message into a
ByteBuf . |
acceptOutboundMessage, allocateBuffer, write
bind, channelActive, channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, exceptionCaught, flush, handlerAdded, handlerRemoved, isSharable, read, userEventTriggered
public ProtobufVarint32LengthFieldPrepender()
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception
MessageToByteEncoder
ByteBuf
. This method will be called for each written message that can be handled
by this encoder.encode
in class MessageToByteEncoder<ByteBuf>
ctx
- the ChannelHandlerContext
which this MessageToByteEncoder
belongs tomsg
- the message to encodeout
- the ByteBuf
into which the encoded message will be writtenException
- is thrown if an error accourCopyright © 2008–2015 The Netty Project. All rights reserved.