google.com/p/protobuf/">Google Protocol Buffers {@link Message} and {@link MessageLite} into a{@link ChannelBuffer}. 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 ChannelBuffer}as a message:
void messageReceived( {@link ChannelHandlerContext} ctx, {@link MessageEvent} e) {MyMessage req = (MyMessage) e.getMessage(); MyMessage res = MyMessage.newBuilder().setText( "Did you say '" + req.getText() + "'?").build(); ch.write(res); }
@author
The Netty Project
@author
Trustin Lee
@version $Rev:231 $, $Date:2008-06-12 16:44:50 +0900 (목, 12 6월 2008) $
@apiviz.landmark