Search in sources :

Example 96 with ChannelPipeline

use of io.netty.channel.ChannelPipeline in project flink by apache.

the class RouterHandler method routed.

private void routed(ChannelHandlerContext channelHandlerContext, RouteResult<?> routeResult, HttpRequest httpRequest) {
    ChannelInboundHandler handler = (ChannelInboundHandler) routeResult.target();
    // The handler may have been added (keep alive)
    ChannelPipeline pipeline = channelHandlerContext.pipeline();
    ChannelHandler addedHandler = pipeline.get(ROUTED_HANDLER_NAME);
    if (handler != addedHandler) {
        if (addedHandler == null) {
            pipeline.addAfter(ROUTER_HANDLER_NAME, ROUTED_HANDLER_NAME, handler);
        } else {
            pipeline.replace(addedHandler, ROUTED_HANDLER_NAME, handler);
        }
    }
    RoutedRequest<?> request = new RoutedRequest<>(routeResult, httpRequest);
    channelHandlerContext.fireChannelRead(request.retain());
}
Also used : ChannelHandler(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler) SimpleChannelInboundHandler(org.apache.flink.shaded.netty4.io.netty.channel.SimpleChannelInboundHandler) ChannelInboundHandler(org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler) ChannelPipeline(org.apache.flink.shaded.netty4.io.netty.channel.ChannelPipeline)

Example 97 with ChannelPipeline

use of io.netty.channel.ChannelPipeline in project netty-socketio by mrniko.

the class SocketIOChannelInitializer method initChannel.

@Override
protected void initChannel(Channel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    addSslHandler(pipeline);
    addSocketioHandlers(pipeline);
}
Also used : ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 98 with ChannelPipeline

use of io.netty.channel.ChannelPipeline in project netty by netty.

the class Socks4ProxyHandler method addCodec.

@Override
protected void addCodec(ChannelHandlerContext ctx) throws Exception {
    ChannelPipeline p = ctx.pipeline();
    String name = ctx.name();
    Socks4ClientDecoder decoder = new Socks4ClientDecoder();
    p.addBefore(name, null, decoder);
    decoderName = p.context(decoder).name();
    encoderName = decoderName + ".encoder";
    p.addBefore(name, encoderName, Socks4ClientEncoder.INSTANCE);
}
Also used : Socks4ClientDecoder(io.netty.handler.codec.socksx.v4.Socks4ClientDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 99 with ChannelPipeline

use of io.netty.channel.ChannelPipeline in project netty by netty.

the class Socks4ProxyServer method configure.

@Override
protected void configure(SocketChannel ch) throws Exception {
    ChannelPipeline p = ch.pipeline();
    switch(testMode) {
        case INTERMEDIARY:
            p.addLast(new Socks4ServerDecoder());
            p.addLast(Socks4ServerEncoder.INSTANCE);
            p.addLast(new Socks4IntermediaryHandler());
            break;
        case TERMINAL:
            p.addLast(new Socks4ServerDecoder());
            p.addLast(Socks4ServerEncoder.INSTANCE);
            p.addLast(new Socks4TerminalHandler());
            break;
        case UNRESPONSIVE:
            p.addLast(UnresponsiveHandler.INSTANCE);
            break;
    }
}
Also used : Socks4ServerDecoder(io.netty.handler.codec.socksx.v4.Socks4ServerDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 100 with ChannelPipeline

use of io.netty.channel.ChannelPipeline in project netty by netty.

the class HttpProxyServer method configure.

@Override
protected void configure(SocketChannel ch) throws Exception {
    ChannelPipeline p = ch.pipeline();
    switch(testMode) {
        case INTERMEDIARY:
            p.addLast(new HttpServerCodec());
            p.addLast(new HttpObjectAggregator(1));
            p.addLast(new HttpIntermediaryHandler());
            break;
        case TERMINAL:
            p.addLast(new HttpServerCodec());
            p.addLast(new HttpObjectAggregator(1));
            p.addLast(new HttpTerminalHandler());
            break;
        case UNRESPONSIVE:
            p.addLast(UnresponsiveHandler.INSTANCE);
            break;
    }
}
Also used : HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) ChannelPipeline(io.netty.channel.ChannelPipeline)

Aggregations

ChannelPipeline (io.netty.channel.ChannelPipeline)331 SocketChannel (io.netty.channel.socket.SocketChannel)95 Channel (io.netty.channel.Channel)86 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)84 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)77 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)74 Bootstrap (io.netty.bootstrap.Bootstrap)72 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)62 ChannelFuture (io.netty.channel.ChannelFuture)61 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)57 HttpObjectAggregator (io.netty.handler.codec.http.HttpObjectAggregator)57 EventLoopGroup (io.netty.channel.EventLoopGroup)49 InetSocketAddress (java.net.InetSocketAddress)43 SslHandler (io.netty.handler.ssl.SslHandler)42 HttpServerCodec (io.netty.handler.codec.http.HttpServerCodec)37 IOException (java.io.IOException)35 LoggingHandler (io.netty.handler.logging.LoggingHandler)33 StringDecoder (io.netty.handler.codec.string.StringDecoder)32 IdleStateHandler (io.netty.handler.timeout.IdleStateHandler)30 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)29