コード例 #1
0
 @Override
 public void channelActive(ChannelHandlerContext ctx) throws Exception {
   channel = ctx.channel();
   channels.add(channel);
   attempts = 0;
   ctx.fireChannelActive();
 }
コード例 #2
0
ファイル: SslHandler.java プロジェクト: njutony1991/netty
 /** Issues an initial TLS handshake once connected when used in client-mode */
 @Override
 public void channelActive(final ChannelHandlerContext ctx) throws Exception {
   if (!startTls && engine.getUseClientMode()) {
     // Begin the initial handshake
     handshake(null);
   }
   ctx.fireChannelActive();
 }
コード例 #3
0
ファイル: NettyHttpServer.java プロジェクト: huntc/trireme
 @Override
 public void channelActive(ChannelHandlerContext ctx) throws Exception {
   if (log.isDebugEnabled()) {
     log.debug("New server-side connection {}", ctx.channel());
   }
   stub.onConnection();
   ctx.fireChannelActive();
 }
コード例 #4
0
  @Override
  public void channelActive(final ChannelHandlerContext ctx) throws Exception {
    ctx.fireChannelActive();

    request =
        new NettyHttpChannel<>(
            tcpStream, new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"));

    request.keepAlive(true);

    handler
        .apply(request)
        .subscribe(
            new DefaultSubscriber<Void>() {
              @Override
              public void onSubscribe(final Subscription s) {
                if (request.checkHeader()) {
                  writeFirst(ctx)
                      .addListener(
                          new ChannelFutureListener() {
                            @Override
                            public void operationComplete(ChannelFuture future) throws Exception {
                              if (future.isSuccess()) {
                                s.request(Long.MAX_VALUE);
                              } else {
                                log.error(
                                    "Error processing initial headers. Closing the channel.",
                                    future.cause());
                                s.cancel();
                                if (ctx.channel().isOpen()) {
                                  ctx.channel().close();
                                }
                              }
                            }
                          });
                } else {
                  s.request(Long.MAX_VALUE);
                }
              }

              @Override
              public void onError(Throwable t) {
                log.error("Error processing connection. Closing the channel.", t);
                if (ctx.channel().isOpen()) {
                  ctx.channel().close();
                }
              }

              @Override
              public void onComplete() {
                writeLast(ctx);
              }
            });
  }
コード例 #5
0
  static void pingBeforeActivate(
      final AsyncCommand<?, ?, ?> cmd,
      final SettableFuture<Boolean> initializedFuture,
      final ChannelHandlerContext ctx,
      final List<ChannelHandler> handlers)
      throws Exception {
    cmd.handle(
        (o, throwable) -> {
          if (throwable == null) {
            initializedFuture.set(true);
            ctx.fireChannelActive();
          } else {
            initializedFuture.setException(throwable);
          }
          return null;
        });

    ctx.channel().writeAndFlush(cmd);
  }
コード例 #6
0
ファイル: SslHandler.java プロジェクト: hsoumare/netty
 /** Issues a SSL handshake once connected when used in client-mode */
 @Override
 public void channelActive(final ChannelHandlerContext ctx) throws Exception {
   if (!startTls && engine.getUseClientMode()) {
     // issue and handshake and add a listener to it which will fire an exception event if
     // an exception was thrown while doing the handshake
     handshake()
         .addListener(
             new GenericFutureListener<Future<Channel>>() {
               @Override
               public void operationComplete(Future<Channel> future) throws Exception {
                 if (!future.isSuccess()) {
                   logger.debug("Failed to complete handshake", future.cause());
                   ctx.close();
                 }
               }
             });
   }
   ctx.fireChannelActive();
 }
コード例 #7
0
ファイル: SslHandler.java プロジェクト: zoopnin/netty
  /** Calls {@link #handshake()} once the {@link Channel} is connected */
  @Override
  public void channelActive(final ChannelHandlerContext ctx) throws Exception {
    if (!startTls && engine.getUseClientMode()) {
      // issue and handshake and add a listener to it which will fire an exception event if
      // an exception was thrown while doing the handshake
      handshake()
          .addListener(
              new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                  if (!future.isSuccess()) {
                    ctx.pipeline().fireExceptionCaught(future.cause());
                    ctx.close();
                  }
                }
              });
    }

    ctx.fireChannelActive();
  }
コード例 #8
0
 @Override
 public void channelActive(ChannelHandlerContext ctx) throws Exception {
   LOGGER.debug(logIdent(ctx, endpoint) + "Channel Active.");
   remoteHostname = ctx.channel().remoteAddress().toString();
   ctx.fireChannelActive();
 }
コード例 #9
0
 @Override
 public void channelActive(final ChannelHandlerContext ctx) throws Exception {
   group.add(ctx.channel());
   ctx.fireChannelActive();
 }
コード例 #10
0
 @Override
 public void sendNextLayerActive() {
   context.fireChannelActive();
 }