io.netty.channel.ChannelHandlerContext#fireChannelReadComplete ( )源码实例Demo

下面列出了io.netty.channel.ChannelHandlerContext#fireChannelReadComplete ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: sofa-bolt   文件: AbstractBatchDecoder.java
@Override
public final void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
    ByteBuf buf = internalBuffer();
    int readable = buf.readableBytes();
    if (readable > 0) {
        ByteBuf bytes = buf.readBytes(readable);
        buf.release();
        ctx.fireChannelRead(bytes);
    } else {
        buf.release();
    }
    cumulation = null;
    numReads = 0;
    ctx.fireChannelReadComplete();
    handlerRemoved0(ctx);
}
 
源代码2 项目: netty4.0.27Learn   文件: ByteToMessageDecoder.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    if (cumulation != null && !first && 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().
        //
        // See:
        // - https://github.com/netty/netty/issues/2327
        // - https://github.com/netty/netty/issues/1764
        cumulation.discardSomeReadBytes();
    }
    ctx.fireChannelReadComplete();
}
 
源代码3 项目: netty-4.1.22   文件: FlowControlHandler.java
/**
 * Dequeues one or many (or none) messages depending on the channel's auto
 * reading state and returns the number of messages that were consumed from
 * the internal queue.
 *
 * The {@code minConsume} argument is used to force {@code dequeue()} into
 * consuming that number of messages regardless of the channel's auto
 * reading configuration.
 *
 * @see #read(ChannelHandlerContext)
 * @see #channelRead(ChannelHandlerContext, Object)
 * 根据通道的自动读取状态对一个或多个(或多个)消息进行反队列处理,并返回从内部队列中消费的消息数量。minuse参数用于强制dequeue()使用该数量的消息,而不考虑通道的自动读取配置。
 */
private int dequeue(ChannelHandlerContext ctx, int minConsume) {
    if (queue != null) {

        int consumed = 0;

        Object msg;
        while ((consumed < minConsume) || config.isAutoRead()) {
            msg = queue.poll();
            if (msg == null) {
                break;
            }

            ++consumed;
            ctx.fireChannelRead(msg);
        }

        // We're firing a completion event every time one (or more)
        // messages were consumed and the queue ended up being drained
        // to an empty state.
        if (queue.isEmpty() && consumed > 0) {
            ctx.fireChannelReadComplete();
        }

        return consumed;
    }

    return 0;
}
 
源代码4 项目: tftp4j   文件: TftpExceptionHandler.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    try {
        ctx.fireChannelReadComplete();
    } catch (Throwable t) {
        ctx.fireExceptionCaught(t);
    }
}
 
源代码5 项目: netty-4.1.22   文件: ByteToMessageDecoder.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    numReads = 0;
    discardSomeReadBytes();
    if (decodeWasNull) {
        decodeWasNull = false;
        if (!ctx.channel().config().isAutoRead()) {
            ctx.read();
        }
    }
    ctx.fireChannelReadComplete();
}
 
源代码6 项目: netty-4.1.22   文件: MessageAggregator.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    // We might need keep reading the channel until the full message is aggregated.我们可能需要一直读取通道,直到聚合完整的消息。
    //
    // See https://github.com/netty/netty/issues/6583
    if (currentMessage != null && !ctx.channel().config().isAutoRead()) {
        ctx.read();
    }
    ctx.fireChannelReadComplete();
}
 
源代码7 项目: aws-sdk-java-v2   文件: HttpStreamsHandler.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    if (ignoreBodyRead) {
        ctx.read();
    } else {
        ctx.fireChannelReadComplete();
    }
}
 
源代码8 项目: panama   文件: HttpWebSocketRequestHandler.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    if (isWebSocket) {
        if (stringBuilder != null) {
            NettyWebSocketRequest nettyWebSocketRequest = new NettyWebSocketRequest(ctx, new TextWebSocketFrame(stringBuilder.toString()));
            nettyWebSocketRequest.setMessage(nettyWebSocketRequest.message());
            webSocketHandler.doRequest(nettyWebSocketRequest);
            stringBuilder = null;
        }

        ctx.fireChannelReadComplete();
    } else {
        super.channelReadComplete(ctx);
    }
}
 
源代码9 项目: sofa-bolt   文件: AbstractBatchDecoder.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    numReads = 0;
    discardSomeReadBytes();
    if (decodeWasNull) {
        decodeWasNull = false;
        if (!ctx.channel().config().isAutoRead()) {
            ctx.read();
        }
    }
    ctx.fireChannelReadComplete();
}
 
源代码10 项目: reactor-netty   文件: SslProvider.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) {
	if (!handshakeDone) {
		ctx.read(); /* continue consuming. */
	}
	ctx.fireChannelReadComplete();
}
 
源代码11 项目: Bats   文件: ProtobufLengthDecoder.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
  ctx.fireChannelReadComplete();
}
 
源代码12 项目: spring-boot-netty   文件: ExceptionHandlerFilter.java
@Override
public void channelReadComplete(final ChannelHandlerContext ctx) throws Exception {
    counter.arrive();
    ctx.fireChannelReadComplete();
}
 
源代码13 项目: Ak47   文件: NettyChannelHandlerAdapter.java
@Override
public void channelReadComplete(ChannelHandlerContext nettyctx) throws Exception {
    log.debug("channelReadComplete().");
    
    nettyctx.fireChannelReadComplete();
}
 
源代码14 项目: xio   文件: ConnectionLimiter.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
  ctx.fireChannelReadComplete();
}
 
源代码15 项目: xio   文件: XioResponseClassifier.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
  ctx.fireChannelReadComplete();
}
 
源代码16 项目: riiablo   文件: ReliableChannelHandler.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
  Gdx.app.debug(TAG, "channelReadComplete");
  ctx.fireChannelReadComplete();
}
 
源代码17 项目: dremio-oss   文件: MessageDecoder.java
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
  ctx.fireChannelReadComplete();
}
 
源代码18 项目: Ak47   文件: Netty4ChannelHandlerAdapter.java
@Override
public void channelReadComplete(ChannelHandlerContext nettyctx) throws Exception {
    nettyctx.fireChannelReadComplete();
}
 
源代码19 项目: jfxvnc   文件: FramebufferUpdateRectDecoder.java
@Override
public boolean decode(ChannelHandlerContext ctx, ByteBuf m, List<Object> out) throws Exception {

  if (state == State.INIT) {
    if (logger.isTraceEnabled()) {
      logger.trace("init readable {} bytes", m.readableBytes());
    }
    if (!m.isReadable()) {
      return false;
    }
    if (m.getByte(0) != ServerEvent.FRAMEBUFFER_UPDATE.getType()) {
      logger.error("no FBU type!!! {}", m.getByte(0));
      ctx.fireChannelReadComplete();
      return false;
    }
    if (!m.isReadable(4)) {
      return false;
    }
    m.skipBytes(2); // padding
    numberRects = m.readUnsignedShort();
    currentRect = 0;
    if (logger.isTraceEnabled()) {
      logger.trace("number of rectangles: {}", numberRects);
    }
    if (numberRects < 1) {
      return true;
    }
    state = State.NEW_RECT;
  }

  if (state == State.NEW_RECT) {
    if (!readRect(ctx, m, out)) {
      return false;
    }
    state = State.READ_RECT;
  }

  FrameRectDecoder dec = frameRectDecoder.get(rect.getEncoding());
  if (dec == null) {
    throw new ProtocolException("Encoding not supported: " + rect.getEncoding());
  }
  dec.setRect(rect);
  if (!dec.decode(ctx, m, out)) {
    return false;
  }

  if (currentRect == numberRects) {
    state = State.INIT;
    ctx.fireUserEventTriggered(ProtocolState.FBU_REQUEST);
    return true;
  }

  if (!readRect(ctx, m, out)) {
    state = State.NEW_RECT;
  }
  return false;
}
 
源代码20 项目: azure-cosmosdb-java   文件: RntbdRequestManager.java
/**
 * The {@link Channel} of the {@link ChannelHandlerContext} has fully consumed the most-recent message read.
 * <p>
 * If {@link ChannelOption#AUTO_READ} is off, no further attempt to read inbound data from the current
 * {@link Channel} will be made until {@link ChannelHandlerContext#read} is called. This leaves time
 * for outbound messages to be written.
 *
 * @param context {@link ChannelHandlerContext} to which this {@link RntbdRequestManager} belongs
 */
@Override
public void channelReadComplete(final ChannelHandlerContext context) {
    this.traceOperation(context, "channelReadComplete");
    this.timestamps.channelReadCompleted();
    context.fireChannelReadComplete();
}