Example usage for io.netty.channel ChannelPipeline addFirst

List of usage examples for io.netty.channel ChannelPipeline addFirst

Introduction

In this page you can find the example usage for io.netty.channel ChannelPipeline addFirst.

Prototype

ChannelPipeline addFirst(ChannelHandler... handlers);

Source Link

Document

Inserts ChannelHandler s at the first position of this pipeline.

Usage

From source file:org.wso2.extension.siddhi.io.tcp.transport.TCPNettyClient.java

License:Open Source License

public TCPNettyClient(int numberOfThreads, boolean keepAlive, boolean noDelay) {
    group = new NioEventLoopGroup(numberOfThreads);
    bootstrap = new Bootstrap();
    bootstrap.group(group).channel(NioSocketChannel.class).option(ChannelOption.SO_KEEPALIVE, keepAlive)
            .option(ChannelOption.TCP_NODELAY, noDelay).handler(new ChannelInitializer<SocketChannel>() {
                @Override//from  w w w  . j  ava 2s.  c om
                protected void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline pipeline = ch.pipeline();
                    pipeline.addFirst(new MessageEncoder());
                }
            });
}