List of usage examples for io.netty.handler.codec.protobuf ProtobufDecoder ProtobufDecoder
public ProtobufDecoder(MessageLite prototype, ExtensionRegistryLite extensionRegistry)
From source file:com.googlecode.protobuf.pro.duplex.client.DuplexTcpClientPipelineFactory.java
License:Apache License
@Override protected void initChannel(Channel ch) throws Exception { ChannelPipeline p = ch.pipeline();/* w w w . j a va 2 s. c o m*/ RpcSSLContext ssl = getSslContext(); if (ssl != null) { p.addLast(Handler.SSL, new SslHandler(ssl.createClientEngine())); } p.addLast(Handler.FRAME_DECODER, new ProtobufVarint32FrameDecoder()); p.addLast(Handler.PROTOBUF_DECODER, new ProtobufDecoder(DuplexProtocol.WirePayload.getDefaultInstance(), getWirelinePayloadExtensionRegistry())); p.addLast(Handler.FRAME_ENCODER, new ProtobufVarint32LengthFieldPrepender()); p.addLast(Handler.PROTOBUF_ENCODER, new ProtobufEncoder()); // the connectResponseHandler is swapped after the client connection // handshake with the RpcClient for the Channel p.addLast(Handler.CLIENT_CONNECT, new ClientConnectResponseHandler()); }
From source file:com.googlecode.protobuf.pro.duplex.server.DuplexTcpServerPipelineFactory.java
License:Apache License
@Override protected void initChannel(Channel ch) throws Exception { ChannelPipeline p = ch.pipeline();// www.jav a 2 s. com if (getSslContext() != null) { p.addLast(Handler.SSL, new SslHandler(getSslContext().createServerEngine())); } p.addLast(Handler.FRAME_DECODER, new ProtobufVarint32FrameDecoder()); p.addLast(Handler.PROTOBUF_DECODER, new ProtobufDecoder(DuplexProtocol.WirePayload.getDefaultInstance(), getWirelinePayloadExtensionRegistry())); p.addLast(Handler.FRAME_ENCODER, new ProtobufVarint32LengthFieldPrepender()); p.addLast(Handler.PROTOBUF_ENCODER, new ProtobufEncoder()); p.addLast(Handler.SERVER_CONNECT, connectRequestHandler); // one instance shared by all channels if (log.isDebugEnabled()) { log.debug("initChannel " + ch); } }