Examples of ProtobufEncoder


Examples of io.netty.handler.codec.protobuf.ProtobufEncoder

        ChannelPipeline p = ch.pipeline();
        p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
        p.addLast("protobufDecoder", new ProtobufDecoder(WorldClockProtocol.Locations.getDefaultInstance()));

        p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
        p.addLast("protobufEncoder", new ProtobufEncoder());

        p.addLast("handler", new WorldClockServerHandler());
    }
View Full Code Here

Examples of io.netty.handler.codec.protobuf.ProtobufEncoder

        ChannelPipeline p = ch.pipeline();
        p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
        p.addLast("protobufDecoder", new ProtobufDecoder(WorldClockProtocol.LocalTimes.getDefaultInstance()));

        p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
        p.addLast("protobufEncoder", new ProtobufEncoder());

        p.addLast("handler", new WorldClockClientHandler());
    }
View Full Code Here

Examples of io.netty.handler.codec.protobuf.ProtobufEncoder

        ChannelPipeline p = pipeline();
        p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
        p.addLast("protobufDecoder", new ProtobufDecoder(LocalTimeProtocol.Locations.getDefaultInstance()));

        p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
        p.addLast("protobufEncoder", new ProtobufEncoder());

        p.addLast("handler", new LocalTimeServerHandler());
        return p;
    }
View Full Code Here

Examples of io.netty.handler.codec.protobuf.ProtobufEncoder

        ChannelPipeline p = pipeline();
        p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
        p.addLast("protobufDecoder", new ProtobufDecoder(LocalTimeProtocol.LocalTimes.getDefaultInstance()));

        p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
        p.addLast("protobufEncoder", new ProtobufEncoder());

        p.addLast("handler", new LocalTimeClientHandler());
        return p;
    }
View Full Code Here

Examples of io.netty.handler.codec.protobuf.ProtobufEncoder

    @Override
    protected void initChannel(Channel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        pipeline.addLast(new ProtobufVarint32FrameDecoder());
        pipeline.addLast(new ProtobufEncoder());
        pipeline.addLast(new ProtobufDecoder(lite));
        pipeline.addLast(new ObjectHandler());
    }
View Full Code Here

Examples of muduo.codec.ProtobufEncoder

        assertEquals(empty, message);
    }

    @Test
    public void testQuery() throws Exception {
        ProtobufEncoder encoder = new ProtobufEncoder();
        Query query = Query.newBuilder()
                .setId(1)
                .setQuestioner("Chen Shuo")
                .addQuestion("Running?")
                .build();
        ChannelBuffer buf = (ChannelBuffer) encoder.encode(null, null, query);

        ProtobufDecoder decoder = new ProtobufDecoder();
        decoder.addMessageType(Query.getDefaultInstance());
        Message message = (Message) decoder.decode(null, null, buf);
        assertEquals(query, message);
View Full Code Here

Examples of muduo.codec.ProtobufEncoder

        assertEquals(query, message);
    }

    @Test
    public void testQuery2() throws Exception {
        ProtobufEncoder encoder = new ProtobufEncoder();
        Query query = Query.newBuilder()
                .setId(1)
                .setQuestioner("Chen Shuo")
                .addQuestion("Running?")
                .build();
        ChannelBuffer buf = (ChannelBuffer) encoder.encode(null, null, query);
        ChannelBuffer buf2 = new BigEndianHeapChannelBuffer(buf.readableBytes() + 8);
        buf2.writeInt(123);
        buf2.writeBytes(buf);

        buf2.readInt();
View Full Code Here

Examples of muduo.codec.ProtobufEncoder

public class CodecTest {

    @Test
    public void testEncoderEmpty() throws Exception {
        ProtobufEncoder encoder = new ProtobufEncoder();
        Empty empty = Empty.getDefaultInstance();
        encoder.encode(null, null, empty);
    }
View Full Code Here

Examples of muduo.codec.ProtobufEncoder

        encoder.encode(null, null, empty);
    }

    @Test
    public void testDecodeEmpty() throws Exception {
        ProtobufEncoder encoder = new ProtobufEncoder();
        Empty empty = Empty.getDefaultInstance();
        ChannelBuffer buf = (ChannelBuffer) encoder.encode(null, null, empty);

        ProtobufDecoder decoder = new ProtobufDecoder();
        decoder.addMessageType(Empty.getDefaultInstance());
        Message message = (Message) decoder.decode(null, null, buf);
        assertEquals(empty, message);
View Full Code Here

Examples of org.jboss.netty.handler.codec.protobuf.ProtobufEncoder

      // Can't be NiO with Netty today => not implemented in Netty.
      DatagramChannelFactory f = new OioDatagramChannelFactory(service);

      ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
      b.setPipeline(Channels.pipeline(new ProtobufEncoder(),
          new ChannelUpstreamHandler() {
            @Override
            public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)
                throws Exception {
              // We're just writing here. Discard any incoming data. See HBASE-8466.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.