コード例 #1
0
ファイル: SslHandler.java プロジェクト: njutony1991/netty
  @Override
  public void read(ChannelHandlerContext ctx) throws Exception {
    if (!handshakePromise.isDone()) {
      readDuringHandshake = true;
    }

    ctx.read();
  }
コード例 #2
0
 @Override
 public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
   try {
     ctx.flush();
   } finally {
     if (!autoRead) {
       ctx.read();
     }
   }
 }
コード例 #3
0
 @Override
 public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
   if (inboundEmitter.requested != 0L) {
     ctx.read();
   } else {
     if (log.isDebugEnabled()) {
       log.debug("Pausing read due to lack of request");
     }
   }
   ctx.fireChannelReadComplete();
 }
コード例 #4
0
  public void channelRead(final ChannelHandlerContext remoteChannelCtx, final Object msg)
      throws Exception {
    LoggerUtil.debug(
        logger, uaChannel.attr(ApnProxyConnectionAttribute.ATTRIBUTE_KEY), "Remote msg", msg);

    remainMsgCount++;

    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();
    }
  }
コード例 #5
0
ファイル: SslHandler.java プロジェクト: njutony1991/netty
  /** Notify all the handshake futures about the successfully handshake */
  private void setHandshakeSuccess() {
    // Work around the JVM crash which occurs when a cipher suite with GCM enabled.
    final String cipherSuite = String.valueOf(engine.getSession().getCipherSuite());
    if (!wantsDirectBuffer && (cipherSuite.contains("_GCM_") || cipherSuite.contains("-GCM-"))) {
      wantsInboundHeapBuffer = true;
    }

    handshakePromise.trySuccess(ctx.channel());

    if (logger.isDebugEnabled()) {
      logger.debug("{} HANDSHAKEN: {}", ctx.channel(), engine.getSession().getCipherSuite());
    }
    ctx.fireUserEventTriggered(SslHandshakeCompletionEvent.SUCCESS);

    if (readDuringHandshake && !ctx.channel().config().isAutoRead()) {
      readDuringHandshake = false;
      ctx.read();
    }
  }
コード例 #6
0
ファイル: SslHandler.java プロジェクト: njutony1991/netty
  @Override
  public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    // Discard bytes of the cumulation buffer if needed.
    discardSomeReadBytes();

    if (needsFlush) {
      needsFlush = false;
      ctx.flush();
    }

    // If handshake is not finished yet, we need more data.
    if (!ctx.channel().config().isAutoRead() && (!firedChannelRead || !handshakePromise.isDone())) {
      // No auto-read used and no message passed through the ChannelPipeline or the handhshake was
      // not complete
      // yet, which means we need to trigger the read to ensure we not encounter any stalls.
      ctx.read();
    }

    firedChannelRead = false;
    ctx.fireChannelReadComplete();
  }
コード例 #7
0
 @Override
 public void read(ChannelHandlerContext ctx) {
   if (!isSuspended(ctx)) {
     ctx.read();
   }
 }
コード例 #8
0
 @Override
 public void run() {
   ctx.attr(READ_SUSPENDED).set(false);
   ctx.read();
 }
コード例 #9
0
 @Override
 public void channelActive(ChannelHandlerContext remoteChannelCtx) throws Exception {
   LoggerUtil.debug(
       logger, uaChannel.attr(ApnProxyConnectionAttribute.ATTRIBUTE_KEY), "Remote channel active");
   remoteChannelCtx.read();
 }
コード例 #10
0
 @Override
 public void read(ChannelHandlerContext ctx) {
   ctx.read();
 }
コード例 #11
0
ファイル: NetworkDispatcher.java プロジェクト: trixmot/mod1
 @Override
 public void read(ChannelHandlerContext ctx) throws Exception {
   ctx.read();
 }