List of usage examples for io.netty.channel ChannelHandlerContext read
@Override ChannelHandlerContext read();
From source file:com.xx_dev.apn.proxy.ApnProxyRemoteForwardHandler.java
License:Apache License
public void channelRead(final ChannelHandlerContext remoteChannelCtx, final Object msg) throws Exception { LoggerUtil.debug(logger, uaChannel.attr(ApnProxyConnectionAttribute.ATTRIBUTE_KEY), "Remote msg", msg); remainMsgCount++;/*from w w w. j av a 2 s.c om*/ if (remainMsgCount <= 5) { remoteChannelCtx.read(); } HttpObject ho = (HttpObject) msg; if (ho instanceof HttpResponse) { HttpResponse httpResponse = (HttpResponse) ho; LoggerUtil.info(forwardRestLogger, uaChannel.attr(ApnProxyConnectionAttribute.ATTRIBUTE_KEY), httpResponse.getStatus(), httpResponse.getProtocolVersion()); httpResponse.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE); httpResponse.headers().set("Proxy-Connection", HttpHeaders.Values.KEEP_ALIVE); } if (uaChannel.isActive()) { uaChannel.writeAndFlush(ho).addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { LoggerUtil.debug(logger, uaChannel.attr(ApnProxyConnectionAttribute.ATTRIBUTE_KEY), "Write to UA finished: " + future.isSuccess()); if (future.isSuccess()) { remainMsgCount--; remoteChannelCtx.read(); LoggerUtil.debug(logger, uaChannel.attr(ApnProxyConnectionAttribute.ATTRIBUTE_KEY), "Fire read again"); } else { remoteChannelCtx.close(); } } }); } else { remoteChannelCtx.close(); } }
From source file:de.jackwhite20.apex.tcp.pipeline.handler.SocketDownstreamHandler.java
License:Open Source License
@Override public void channelActive(ChannelHandlerContext ctx) { ctx.read(); }
From source file:divconq.ctp.net.CtpHandler.java
License:Open Source License
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { // on success the request first read if (evt == SslHandshakeCompletionEvent.SUCCESS) { // make sure auto read is off ctx.channel().config().setAutoRead(false); this.debug("SSL passed"); // do initial read, this is fine - just be sure streaming will work by not always reading ctx.read(); }//w ww.jav a 2s.co m }
From source file:divconq.net.ByteToMessageDecoder.java
License:Apache License
@Override public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { if (this.cumulation != null && !this.first && this.cumulation.refCnt() == 1) { // discard some bytes if possible to make more room in the // buffer but only if the refCnt == 1 as otherwise the user may have // used slice().retain() or duplicate().retain(). ////from www. j a va 2s . c o m // See: // - https://github.com/netty/netty/issues/2327 // - https://github.com/netty/netty/issues/1764 this.cumulation.discardSomeReadBytes(); } if (this.decodeWasNull) { this.decodeWasNull = false; if (ctx.channel().config().isAutoRead()) { ctx.read(); } } ctx.fireChannelReadComplete(); }
From source file:divconq.net.ssl.SslHandler.java
License:Apache License
@Override public void read(ChannelHandlerContext ctx) { ctx.read(); }
From source file:divconq.net.ssl.SslHandler.java
License:Apache License
@Override public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { if (needsFlush) { needsFlush = false;/*from ww w . j a v a2s. co m*/ ctx.flush(); } // if not auto reading but no handshake, then read anyway if (!handshakePromise.isDone() && !ctx.channel().config().isAutoRead()) { ctx.read(); } super.channelReadComplete(ctx); }
From source file:in.voidma.lemming.traffic.TrafficLatencyHandler.java
License:Open Source License
@Override public void read(ChannelHandlerContext ctx) throws Exception { if (inBound) { timer.newTimeout(new TimerTask() { @Override//from ww w . j a va 2 s . c o m public void run(Timeout timeout) throws Exception { ctx.read(); } }, TimeLagMS, TimeUnit.MILLISECONDS); } }
From source file:io.liveoak.container.traversal.BaseResponder.java
License:Open Source License
protected void dispatchInvocation(Runnable invocation) { ChannelHandlerContext context = this.ctx.pipeline().context(RESOURCE_READ_DECODER); HttpRequestBodyHandler.Invocation completion = new HttpRequestBodyHandler.Invocation(invocation); context.fireChannelRead(completion); // signal we're ready to read some more. context.read(); }
From source file:io.liveoak.container.traversal.BaseResponder.java
License:Open Source License
protected void resumeRead() { ChannelPipeline pipeline = ctx.pipeline(); if (pipeline == null) { return;/*from w w w . j av a 2s .co m*/ } ChannelHandlerContext context = pipeline.firstContext(); if (context == null) { return; } context.read(); }
From source file:io.urmia.api.handler.RestApiHandler.java
License:Open Source License
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { log.info("channelActive: {}", ctx); super.channelActive(ctx); ctx.read(); }