google.com/p/protobuf/">Google Protocol Buffers {@link Message} and {@link MessageLite}. Please note that this decoder must be used with a proper {@link ByteToMessageDecoder} such as {@link ProtobufVarint32FrameDecoder}or {@link LengthFieldBasedFrameDecoder} if you are using a stream-basedtransport such as TCP/IP. A typical setup for TCP/IP would be:
{@link ChannelPipeline} pipeline = ...;// Decoders pipeline.addLast("frameDecoder", new {@link LengthFieldBasedFrameDecoder}(1048576, 0, 4, 0, 4)); pipeline.addLast("protobufDecoder", new {@link ProtobufDecoder}(MyMessage.getDefaultInstance())); // Encoder pipeline.addLast("frameEncoder", new {@link LengthFieldPrepender}(4)); pipeline.addLast("protobufEncoder", new {@link ProtobufEncoder}());
and then you can use a {@code MyMessage} instead of a {@link ByteBuf}as a message:
void channelRead( {@link ChannelHandlerContext} ctx, MyMessage req) {MyMessage res = MyMessage.newBuilder().setText( "Did you say '" + req.getText() + "'?").build(); ch.write(res); }