@Override protected void initChannel(SocketChannel channel) throws Exception { configureChannel(channel.config()); ChannelPipeline pipeline = channel.pipeline(); if (isSecure) { Assert.notNull(sslContext, "sslContext should not be null"); pipeline.addLast(sslContext.newHandler(channel.alloc(), uri.getHost(), uri.getPort())); } pipeline.addLast(new HttpClientCodec()); pipeline.addLast(new HttpObjectAggregator(maxResponseSize)); if (readTimeout > 0) { pipeline.addLast(new ReadTimeoutHandler(readTimeout, TimeUnit.MILLISECONDS)); } } });
@Override protected void initChannel(SocketChannel channel) throws Exception { configureChannel(channel.config()); ChannelPipeline pipeline = channel.pipeline(); if (isSecure) { Assert.notNull(sslContext, "sslContext should not be null"); pipeline.addLast(sslContext.newHandler(channel.alloc(), uri.getHost(), uri.getPort())); } pipeline.addLast(new HttpClientCodec()); pipeline.addLast(new HttpObjectAggregator(maxResponseSize)); if (readTimeout > 0) { pipeline.addLast(new ReadTimeoutHandler(readTimeout, TimeUnit.MILLISECONDS)); } } });
@Override protected void initChannel(SocketChannel c) { MessageHandler handler = new MessageHandler(connectionManager); CodecsHandler codecs = new CodecsHandler(ProtocolType.HANDSHAKE.getProtocol()); FramingHandler framing = new FramingHandler(); try { c.config().setOption(ChannelOption.IP_TOS, 0x18); } catch (ChannelException e) { // Not supported on all OSs, like Windows XP and lesser GlowServer.logger.warning("Your OS does not support type of service."); } c.pipeline() .addLast("idle_timeout", new IdleStateHandler(READ_IDLE_TIMEOUT, WRITE_IDLE_TIMEOUT, 0)) .addLast("legacy_ping", new LegacyPingHandler(connectionManager)) .addLast("encryption", NoopHandler.INSTANCE) .addLast("framing", framing) .addLast("compression", NoopHandler.INSTANCE) .addLast("codecs", codecs) .addLast("handler", handler); } }
@Override protected void initChannel(SocketChannel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); if (params != null) { channel.config().setConnectTimeoutMillis( params.getConnectTimeout()); if (options != null) { channel.config().setOptions(options); } pipeline.addLast(new ReadTimeoutHandler(params .getReadTimeout(), TimeUnit.MILLISECONDS)); } pipeline.addLast(new HttpClientCodec()); pipeline.addLast(new HttpContentDecompressor()); pipeline.addLast(new ChunkedWriteHandler()); pipeline.addLast(new HttpResponseDecoder()); pipeline.addLast(new HttpObjectAggregator( Integer.MAX_VALUE)); } });
@Override public boolean getKeepAlive() throws SocketException { return ch.config().getOption(ChannelOption.SO_KEEPALIVE); }
@Override public int getTrafficClass() throws SocketException { return ch.config().getOption(ChannelOption.IP_TOS); }
@Override public void setReuseAddress(boolean on) throws SocketException { ch.config().setOption(ChannelOption.SO_REUSEADDR, on); }
@Override public synchronized int getReceiveBufferSize() throws SocketException { return ch.config().getOption(ChannelOption.SO_RCVBUF); }
@Override public boolean getReuseAddress() throws SocketException { return ch.config().getOption(ChannelOption.SO_REUSEADDR); }
@Override public int getSoLinger() throws SocketException { return ch.config().getOption(ChannelOption.SO_LINGER); }
@Override public boolean getTcpNoDelay() throws SocketException { return ch.config().getOption(ChannelOption.TCP_NODELAY); }
@Override public void setSoLinger(boolean on, int linger) throws SocketException { ch.config().setOption(ChannelOption.SO_LINGER, linger); }
@Override public void setKeepAlive(boolean on) throws SocketException { ch.config().setOption(ChannelOption.SO_KEEPALIVE, on); }
public void setAutoRead(boolean enableAutoRead) { channel.config().setAutoRead(enableAutoRead); }
@Override public void initChannel(SocketChannel channel) { channel.config().setReuseAddress(true); configureServerPipeline(channel.pipeline(), AbstractServerConnector.this); } });
@Override public void initChannel( SocketChannel ch ) throws Exception { ch.config().setAllocator( PooledByteBufAllocator.DEFAULT ); if( sslCtx != null ) { ch.pipeline().addLast( sslCtx.newHandler( ch.alloc() ) ); } ch.pipeline().addLast( new SocketTransportHandler( new SocketTransportHandler.ProtocolChooser( protocolVersions ), logging ) ); } } );
private final void putConnection() { conn.channel.config().setAutoRead(false); InboundHandler handler = (InboundHandler)conn.channel.pipeline().last(); handler.command = null; conn.updateLastUsed(); command.node.putAsyncConnection(conn, eventState.index); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { SocketChannel childChannel = (SocketChannel) msg; childChannel.config().setSoLinger(0); childChannel.unsafe().closeForcibly(); } }).childHandler(new ChannelInboundHandlerAdapter());
private final void putConnection() { conn.channel.config().setAutoRead(false); InboundHandler handler = (InboundHandler)conn.channel.pipeline().last(); handler.command = null; conn.updateLastUsed(); command.node.putAsyncConnection(conn, eventState.index); }
@Override public void connect(SocketAddress endpoint, int timeout) throws IOException { ch.config().setConnectTimeoutMillis(timeout); ch.connect(endpoint).syncUninterruptibly(); }