List of usage examples for io.netty.channel ChannelPipeline remove
<T extends ChannelHandler> T remove(Class<T> handlerType);
From source file:com.alibaba.dubbo.qos.server.handler.QosProcessHandler.java
License:Apache License
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { if (in.readableBytes() < 1) { return;// w w w. j a v a 2 s. co m } // read one byte to guess protocol final int magic = in.getByte(in.readerIndex()); ChannelPipeline p = ctx.pipeline(); p.addLast(new LocalHostPermitHandler(acceptForeignIp)); if (isHttp(magic)) { // no welcome output for http protocol if (welcomeFuture != null && welcomeFuture.isCancellable()) { welcomeFuture.cancel(false); } p.addLast(new HttpServerCodec()); p.addLast(new HttpObjectAggregator(1048576)); p.addLast(new HttpProcessHandler()); p.remove(this); } else { p.addLast(new LineBasedFrameDecoder(2048)); p.addLast(new StringDecoder(CharsetUtil.UTF_8)); p.addLast(new StringEncoder(CharsetUtil.UTF_8)); p.addLast(new IdleStateHandler(0, 0, 5 * 60)); p.addLast(new TelnetProcessHandler()); p.remove(this); } }
From source file:com.corundumstudio.socketio.transport.FlashSocketTransport.java
License:Apache License
@Override protected void removeHandler(ChannelPipeline pipeline) { pipeline.remove(SocketIOChannelInitializer.WEB_SOCKET_TRANSPORT); }
From source file:com.flysoloing.learning.network.netty.portunification.PortUnificationServerHandler.java
License:Apache License
private void enableSsl(ChannelHandlerContext ctx) { ChannelPipeline p = ctx.pipeline(); p.addLast("ssl", sslCtx.newHandler(ctx.alloc())); p.addLast("unificationA", new PortUnificationServerHandler(sslCtx, false, detectGzip)); p.remove(this); }
From source file:com.flysoloing.learning.network.netty.portunification.PortUnificationServerHandler.java
License:Apache License
private void enableGzip(ChannelHandlerContext ctx) { ChannelPipeline p = ctx.pipeline(); p.addLast("gzipdeflater", ZlibCodecFactory.newZlibEncoder(ZlibWrapper.GZIP)); p.addLast("gzipinflater", ZlibCodecFactory.newZlibDecoder(ZlibWrapper.GZIP)); p.addLast("unificationB", new PortUnificationServerHandler(sslCtx, detectSsl, false)); p.remove(this); }
From source file:com.flysoloing.learning.network.netty.portunification.PortUnificationServerHandler.java
License:Apache License
private void switchToHttp(ChannelHandlerContext ctx) { ChannelPipeline p = ctx.pipeline(); p.addLast("decoder", new HttpRequestDecoder()); p.addLast("encoder", new HttpResponseEncoder()); p.addLast("deflater", new HttpContentCompressor()); p.addLast("handler", new HttpSnoopServerHandler()); p.remove(this); }
From source file:com.flysoloing.learning.network.netty.portunification.PortUnificationServerHandler.java
License:Apache License
private void switchToFactorial(ChannelHandlerContext ctx) { ChannelPipeline p = ctx.pipeline(); p.addLast("decoder", new BigIntegerDecoder()); p.addLast("encoder", new NumberEncoder()); p.addLast("handler", new FactorialServerHandler()); p.remove(this); }
From source file:com.friz.update.network.UpdateSessionContext.java
License:Open Source License
public void writeSuccess(int status) { channel.writeAndFlush(new UpdateResponseEvent(status)).addListener(new ChannelFutureListener() { @Override/*from w ww . ja va2 s .c o m*/ public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { ChannelPipeline p = future.channel().pipeline(); p.remove(UpdateInitDecoder.class); p.remove(UpdateInitEncoder.class); p.addFirst(XorEncoder.class.getName(), new XorEncoder()); p.addFirst(UpdateEncoder.class.getName(), new UpdateEncoder()); p.addFirst(UpdateDecoder.class.getName(), new UpdateDecoder()); handshakeComplete = true; } } }); }
From source file:com.hazelcast.openshift.TunnelClientAcceptor.java
License:Open Source License
@Override protected void channelRead0(ChannelHandlerContext ctx, HttpRequest msg) throws Exception { HttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); ctx.writeAndFlush(response).sync();/* w w w . j av a 2 s . co m*/ ChannelPipeline pipeline = ctx.pipeline(); Channel forward = createRemoteChannel(ctx.channel()); if (forward == null) { ctx.close(); return; } forward.closeFuture().addListener(f -> ctx.close()); ctx.channel().closeFuture().addListener(f -> forward.close()); pipeline.addLast(new ProxyForwardHandler(forward)); pipeline.remove(HttpRequestDecoder.class); pipeline.remove(HttpResponseEncoder.class); pipeline.remove(this); }
From source file:com.hazelcast.openshift.TunnelServerConnector.java
License:Open Source License
@Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { Promise promise = new Promise(); Bootstrap bootstrap = createBootstrap(ctx.channel(), promise); ChannelFuture future = bootstrap.connect(httpHost, httpPort); Channel forward = future.sync().channel(); forward.closeFuture().addListener(f -> ctx.close()); ctx.channel().closeFuture().addListener(f -> forward.close()); HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.CONNECT, "/"); request.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE); forward.writeAndFlush(request);/*from ww w .j a v a 2s.co m*/ // Wait for the initial http response (ssl established) promise.sync(10, TimeUnit.SECONDS); // Exchange the HazelcastClient -> TunnelClient handler to proxy ChannelPipeline pipeline = ctx.pipeline(); pipeline.addLast(new ProxyForwardHandler(forward)); pipeline.remove(this); ctx.fireChannelRegistered(); }
From source file:com.heliosapm.streams.onramp.GZipDetector.java
License:Apache License
private void enableGzip(final ChannelHandlerContext ctx) { final ChannelPipeline p = ctx.pipeline(); try {/* www . ja va 2s . c om*/ // p.addAfter("connmgr", "gzipdeflater", new JZlibEncoder(ZlibWrapper.GZIP){ // // TODO // }); p.addAfter("gzipdetector", "gzipinflater", ZlibCodecFactory.newZlibDecoder(ZlibWrapper.GZIP)); p.remove(this); } catch (Exception ex) { log.error("Failed to add gzip handlers", ex); } }