Example usage for io.netty.channel ChannelHandlerContext fireChannelActive

List of usage examples for io.netty.channel ChannelHandlerContext fireChannelActive

Introduction

In this page you can find the example usage for io.netty.channel ChannelHandlerContext fireChannelActive.

Prototype

@Override
    ChannelHandlerContext fireChannelActive();

Source Link

Usage

From source file:org.rzo.netty.ahessian.session.ClientSessionFilter.java

License:Apache License

private void handleSession(ChannelHandlerContext ctx, HandlerList pipeline) {
    _hasSession = true;//from ww w .  j a v a2s .c o m
    // now that we have a session extend the pipeline
    pipeline.mixin(ctx);
    ctx.channel().attr(SESSION).set(_session);
    ctx.fireChannelActive();
}

From source file:org.rzo.netty.ahessian.session.ServerSessionFilter.java

License:Apache License

private void handleSession(ChannelHandlerContext ctx, Session session, HandlerList pipeline) {
    _hasSession = true;/*from ww w .j av a  2  s.  c om*/
    session.setClosed(false);

    // if we have a session timeout set, cancel it.
    Timeout timeOut = session.removeTimeout();
    if (timeOut != null)
        timeOut.cancel();

    if (pipeline.hasChannel()) {
        Constants.ahessianLogger.warn(ctx.channel() + " session already attached -> close connection");
        pipeline.close();
    }

    // now that we have a session extend the pipeline
    pipeline.mixin(ctx);
    ctx.channel().attr(SESSION).set(session);
    _channel = ctx.channel();
    // first send session and wait until it has been transmitted
    ctx.writeAndFlush(Unpooled.wrappedBuffer(session.getId().getBytes())).awaitUninterruptibly();
    // only then inform the mixin pipeline that we are connected
    ctx.fireChannelActive();
}

From source file:org.rzo.yajsw.nettyutils.ConditionFilter.java

License:Apache License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    if (_condition.isOk(ctx, null)) {
        // forward if condtion met
        ctx.fireChannelActive();
    } else {//w  w  w . j  a va  2  s . com
        ctx.channel().close();
    }
}

From source file:org.rzo.yajsw.nettyutils.WhitelistFilter.java

License:Apache License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    if (!isBlocked(ctx.channel())) {
        // forward if not blocked
        ctx.fireChannelActive();
    } else {/*from  w ww  .j a va2  s.c  o  m*/
        System.out.println("connection refused : " + ctx.channel().remoteAddress());
        blockSession(ctx.channel());
    }
}

From source file:org.sdnplatform.sync.internal.rpc.HandshakeTimeoutHandler.java

License:Apache License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    if (timeoutNanos > 0) {
        timeout = timer.newTimeout(new HandshakeTimeoutTask(ctx), timeoutNanos, TimeUnit.NANOSECONDS);
    }//from  w  w w .j  a v  a  2 s. c o  m
    ctx.fireChannelActive();
}

From source file:org.wenxueliu.netty.server.HandshakeTimeoutHandler.java

License:Apache License

@Override
public void channelActive(ChannelHandlerContext ctx) {
    if (timeoutNanos > 0) {
        timeout = timer.newTimeout(new HandshakeTimeoutTask(ctx), timeoutNanos, TimeUnit.NANOSECONDS);
    }/*w  ww.  j a va  2s . com*/
    ctx.fireChannelActive();
}

From source file:reactor.io.net.impl.netty.http.NettyHttpClientHandler.java

License:Open Source License

@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);//  w  ww .  j a  va  2 s.c  om

    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);
        }
    });
}

From source file:reactor.io.net.impl.netty.http.NettyHttpServerHandler.java

License:Open Source License

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    ctx.fireChannelActive();
    ctx.read();
}

From source file:reactor.ipc.netty.channel.NettyChannelHandler.java

License:Open Source License

@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
    ctx.fireChannelActive();
    operations(ctx).onChannelActive(ctx);
}

From source file:reactor.ipc.netty.channel.SslReadHandler.java

License:Open Source License

@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
    if (evt instanceof SslHandshakeCompletionEvent) {
        handshakeDone = true;// w  w  w .j a v a  2  s .c o  m
        if (ctx.pipeline().context(this) != null) {
            ctx.pipeline().remove(this);
        }
        SslHandshakeCompletionEvent handshake = (SslHandshakeCompletionEvent) evt;
        if (handshake.isSuccess()) {
            ctx.fireChannelActive();
        } else {
            sink.error(handshake.cause());
        }
    }
    super.userEventTriggered(ctx, evt);
}