Example usage for io.netty.handler.codec LengthFieldBasedFrameDecoder LengthFieldBasedFrameDecoder

List of usage examples for io.netty.handler.codec LengthFieldBasedFrameDecoder LengthFieldBasedFrameDecoder

Introduction

In this page you can find the example usage for io.netty.handler.codec LengthFieldBasedFrameDecoder LengthFieldBasedFrameDecoder.

Prototype

public LengthFieldBasedFrameDecoder(int maxFrameLength, int lengthFieldOffset, int lengthFieldLength,
        int lengthAdjustment, int initialBytesToStrip, boolean failFast) 

Source Link

Document

Creates a new instance.

Usage

From source file:com.github.pgasync.impl.netty.NettyPgProtocolStream.java

License:Apache License

ChannelInitializer<Channel> newProtocolInitializer(ChannelHandler onActive) {
    return new ChannelInitializer<Channel>() {
        @Override/*from   ww  w  .  j a v  a2  s.com*/
        protected void initChannel(Channel channel) throws Exception {
            if (useSsl) {
                channel.pipeline().addLast(newSslInitiator());
            }
            channel.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 1, 4, -4, 0, true));
            channel.pipeline().addLast(new ByteBufMessageDecoder());
            channel.pipeline().addLast(new ByteBufMessageEncoder());
            channel.pipeline().addLast(newProtocolHandler());
            channel.pipeline().addLast(onActive);
        }
    };
}