Example usage for io.netty.handler.codec.socks SocksInitResponseDecoder SocksInitResponseDecoder

List of usage examples for io.netty.handler.codec.socks SocksInitResponseDecoder SocksInitResponseDecoder

Introduction

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

Prototype

public SocksInitResponseDecoder() 

Source Link

Usage

From source file:com.xx_dev.apn.socks.test.SocksClientInitializer.java

License:Apache License

@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    ChannelPipeline p = socketChannel.pipeline();
    p.addLast("log", new LoggingHandler("BYTE_LOGGER", LogLevel.DEBUG));
    p.addLast(new SocksInitResponseDecoder());
    p.addLast(new SocksMessageEncoder());
    p.addLast(new SocksClientHandler());
}

From source file:org.msgpack.rpc.loop.netty.NettyTcpClientTransport.java

License:Apache License

NettyTcpClientTransport(TcpClientConfig config, Session session, NettyEventLoop loop,
        Class<? extends RpcMessageHandler> rpcHandlerClass) {
    super(config, session);

    try {//from  w  w  w.  j  a va 2 s  . c  o m
        handler = rpcHandlerClass.getConstructor(Session.class).newInstance(session);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    //      handler = new RpcMessageHandlerEx(session);
    eventLoop = loop;
    bootstrap = new Bootstrap().group(group);
    bootstrap.channel(NioSocketChannel.class);
    final NettyTcpClientTransport trans = this;
    bootstrap.handler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) throws Exception {
            ChannelPipeline p = ch.pipeline();
            if (isSocks) {
                p.addFirst("socks-handler", new SocksProxyHandler(session, trans));
                p.addFirst("socks-encode", new SocksMessageEncoder());
                p.addFirst("socks-decode", new SocksInitResponseDecoder());
            }
            p.addLast("msgpack-decode-stream", new MessagePackStreamDecoder(eventLoop.getMessagePack()));
            p.addLast("msgpack-encode", new MessagePackEncoder(eventLoop.getMessagePack()));
            p.addLast("message", new MessageHandler(handler, trans));
        }

    });
    bootstrap.option(ChannelOption.TCP_NODELAY, true);
}