google.com/p/protobuf/">Google Protocol Buffers {@link Message} and {@link MessageLite} into a{@link ByteBuf}. 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 messageReceived( {@link ChannelHandlerContext} ctx, MyMessage req) {MyMessage res = MyMessage.newBuilder().setText( "Did you say '" + req.getText() + "'?").build(); ch.write(res); }