Example usage for io.netty.channel ChannelPipeline addLast

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

Introduction

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

Prototype

ChannelPipeline addLast(ChannelHandler... handlers);

Source Link

Document

Inserts ChannelHandler s at the last position of this pipeline.

Usage

From source file:com.hop.hhxx.example.securechat.SecureChatClientInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();

    // Add SSL handler first to encrypt and decrypt everything.
    // In this example, we use a bogus certificate in the server side
    // and accept any invalid certificates in the client side.
    // You will need something more complicated to identify both
    // and server in the real world.
    pipeline.addLast(sslCtx.newHandler(ch.alloc(), io.netty.example.securechat.SecureChatClient.HOST,
            io.netty.example.securechat.SecureChatClient.PORT));

    // On top of the SSL handler, add the text line codec.
    pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    pipeline.addLast(new StringDecoder());
    pipeline.addLast(new StringEncoder());

    // and then business logic.
    pipeline.addLast(new SecureChatClientHandler());
}

From source file:com.hop.hhxx.example.securechat.SecureChatServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();

    // Add SSL handler first to encrypt and decrypt everything.
    // In this example, we use a bogus certificate in the server side
    // and accept any invalid certificates in the client side.
    // You will need something more complicated to identify both
    // and server in the real world.
    pipeline.addLast(sslCtx.newHandler(ch.alloc()));

    // On top of the SSL handler, add the text line codec.
    pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    pipeline.addLast(new StringDecoder());
    pipeline.addLast(new StringEncoder());

    // and then business logic.
    pipeline.addLast(new io.netty.example.securechat.SecureChatServerHandler());
}

From source file:com.hop.hhxx.example.spdy.server.SpdyServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline p = ch.pipeline();
    p.addLast(sslCtx.newHandler(ch.alloc()));
    // Negotiates with the browser if SPDY or HTTP is going to be used
    p.addLast(new io.netty.example.spdy.server.SpdyOrHttpHandler());
}

From source file:com.hop.hhxx.example.telnet.TelnetClientInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline pipeline = ch.pipeline();

    if (sslCtx != null) {
        pipeline.addLast(
                sslCtx.newHandler(ch.alloc(), io.netty.example.telnet.TelnetClient.HOST, TelnetClient.PORT));
    }//from   ww w .ja  v a2  s  . co m

    // Add the text line codec combination first,
    pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    pipeline.addLast(DECODER);
    pipeline.addLast(ENCODER);

    // and then business logic.
    pipeline.addLast(CLIENT_HANDLER);
}

From source file:com.hop.hhxx.example.worldclock.WorldClockClientInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline p = ch.pipeline();
    if (sslCtx != null) {
        p.addLast(sslCtx.newHandler(ch.alloc(), io.netty.example.worldclock.WorldClockClient.HOST,
                io.netty.example.worldclock.WorldClockClient.PORT));
    }// w  w  w  .  jav  a  2  s.  c o m

    p.addLast(new ProtobufVarint32FrameDecoder());
    p.addLast(new ProtobufDecoder(WorldClockProtocol.LocalTimes.getDefaultInstance()));

    p.addLast(new ProtobufVarint32LengthFieldPrepender());
    p.addLast(new ProtobufEncoder());

    p.addLast(new WorldClockClientHandler());
}

From source file:com.hop.hhxx.example.worldclock.WorldClockServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline p = ch.pipeline();
    if (sslCtx != null) {
        p.addLast(sslCtx.newHandler(ch.alloc()));
    }//from ww w.  j a v  a2  s.c  om

    p.addLast(new ProtobufVarint32FrameDecoder());
    p.addLast(
            new ProtobufDecoder(io.netty.example.worldclock.WorldClockProtocol.Locations.getDefaultInstance()));

    p.addLast(new ProtobufVarint32LengthFieldPrepender());
    p.addLast(new ProtobufEncoder());

    p.addLast(new WorldClockServerHandler());
}

From source file:com.hzmsc.scada.Jmtis.server.PortUnificationServerHandler.java

License:Apache License

private void switchToJMAC(ChannelHandlerContext ctx) {
    ChannelPipeline pipeline = ctx.pipeline();
    pipeline.addLast(new LengthFieldBasedFrameDecoder(1024, 4, 4));
    pipeline.addLast(new JmtisDecoder());

    pipeline.addLast(new JmtisHeaderEncoder());
    pipeline.addLast(new JmtisBodyEncoder());

    pipeline.addLast(new JmtisServerHandler());
    pipeline.remove(this);
}

From source file:com.im.socket.netty.web.WebSocketServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    pipeline.addLast(new HttpServerCodec());
    pipeline.addLast(new HttpObjectAggregator(65536));
    pipeline.addLast(new WebSocketServerCompressionHandler());
    pipeline.addLast(new WebSocketServerOnlyProtocolHandler(WEBSOCKET_PATH, null, true));
    pipeline.addLast(new WebSocketFrameHandler());

    // pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH,
    // null, true));
    // System.out.println("WebSocketServerInitializer");
}

From source file:com.im.test.WebSocketServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    pipeline.addLast(new HttpServerCodec());
    pipeline.addLast(new HttpObjectAggregator(65536));
    pipeline.addLast(new WebSocketServerCompressionHandler());
    pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true));
    pipeline.addLast(new WebSocketFrameHandler());
}

From source file:com.intuit.karate.netty.FeatureServerInitializer.java

License:Open Source License

@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline p = ch.pipeline();
    if (sslCtx != null) {
        p.addLast(sslCtx.newHandler(ch.alloc()));
    }/*from w w  w.  java  2s  .c o m*/
    p.addLast(new HttpServerCodec());
    p.addLast(new HttpObjectAggregator(1048576));
    p.addLast(new FeatureServerHandler(backend, sslCtx != null, stopFunction));
}