可以netty suport http(tcp短连接)和谷歌protobuf

时间:2012-05-21 16:43:47

标签: http netty protocol-buffers google-ajax-libraries

这是我的工具,是不是?

public ChannelPipeline getPipeline() throws Exception 
{
    ChannelPipeline p = pipeline();
    pipeline.addLast("decoder", new HttpRequestDecoder());
    p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
    p.addLast("protobufDecoder", new ProtobufDecoder(LocalTimeProtocol.Locations.getDefaultInstance()));
    pipeline.addLast("encoder", new HttpResponseEncoder());
    p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
    p.addLast("protobufEncoder", new ProtobufEncoder());
    p.addLast("handler", new LocalTimeServerHandler());
    return p;
}

1 个答案:

答案 0 :(得分:0)

它无效。您必须编写一个处理程序来获取HTTP请求的内容,并将请求的内容(ChannelBuffer)转换为protobuf消息。下游也需要做类似的工作。