java - How should I arrange the codec handlers in Netty? -


I have a small Netty codec confused, I know I need to add some code to the pipeline But how should I arrange encoder and decoders? Anyone can give a simple explanation of the rules of how to arrange the encoder and decoder in a pipeline

server-side code:

  Protected static zero run () throws exception {ServerBootstrap b = new serverbootstrap (); BGPP (boss group, workgroup); B.channel (NioServerSocketChannel.class); b.childHandler (New ChannelInitializer & LT; SocketChannel & gt; () {@Override public void initChannel (SocketChannel ch) throws an exception {ChannelPipeline pipeline = ch.pipeline (); pipeline.addLast ( "decoder" New HttpRequestDecoder () ); pipeline.addLast (new ProtobufVarint32FrameDecoder ()); pipeline.addLast ( "bufd", new ProtobufDecoder (PbConditions.Conditions.getDefaultInstance ())); pipeline.addLast ( "servercodec", new HttpServerCodec ()); pipeline.addLast ( "aggegator", new HttpObjectAggregator (Integer.MAX_VALUE)); pipeline.addLast (new MemcachedServiceHandler ()); pipeline.addLast ( "", new ProtobufEncoder ()); pipeline.addLast ( "responseencoder", new HttpResponseEncoder ()) ; Pipeline.addLast ("clientcoder", new HTTP client code ());}}); B Bind (IP, Port) .sync (); }  


Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -