Package io.netty.channel

Examples of io.netty.channel.ChannelHandlerContext


        return getSockJsSession().connectionContext().channel().isActive() || getSockJsSession().inuse();
    }

    @Override
    public void onSockJSServerInitiatedClose() {
        final ChannelHandlerContext context = getSockJsSession().connectionContext();
        if (context != null) { //could be null if the request is aborted, for example due to missing callback.
            if (logger.isDebugEnabled()) {
                logger.debug("Will close session connectionContext {}", getSockJsSession().connectionContext());
            }
            context.close();
        }
        sessions.remove(getSockJsSession().sessionId());
    }
View Full Code Here


     *
     * @param ctx the ChannelHandlerContext used establishing a connection.
     */
    public void setConnectionContext(final ChannelHandlerContext ctx) {
        while (true) {
            final ChannelHandlerContext oldCtx = connectionCtx.get();
            if (connectionCtx.compareAndSet(oldCtx, ctx)) {
                return;
            }
        }
    }
View Full Code Here

     *
     * @param ctx the ChannelHandlerContext used when the session is open.
     */
    public void setOpenContext(final ChannelHandlerContext ctx) {
        while (true) {
            final ChannelHandlerContext oldCtx = openCtx.get();
            if (openCtx.compareAndSet(oldCtx, ctx)) {
                return;
            }
        }
    }
View Full Code Here

                if (future.isSuccess()) {
                    ChannelPipeline p = future.channel().pipeline();
                    if (p.get(HttpObjectAggregator.class) != null) {
                        p.remove(HttpObjectAggregator.class);
                    }
                    ChannelHandlerContext ctx = p.context(HttpRequestDecoder.class);
                    if (ctx == null) {
                        // this means the user use a HttpServerCodec
                        ctx = p.context(HttpServerCodec.class);
                        if (ctx == null) {
                            throw new IllegalStateException("No HttpDecoder and no HttpServerCodec in the pipeline");
                        }
                        p.addBefore(ctx.name(), "wsencoder", newWebsocketDecoder());
                        p.replace(ctx.name(), "wsdecoder", newWebSocketEncoder());
                    } else {
                        p.remove(HttpRequestDecoder.class);
                        p.remove(HttpResponseEncoder.class);
                    }
                } else {
View Full Code Here

         *
         * See issue: https://github.com/Netflix/RxNetty/issues/145
         */
        final ChannelHandler timeoutHandler = pipeline.get(READ_TIMEOUT_HANDLER_NAME);
        if (timeoutHandler != null) {
            final ChannelHandlerContext handlerContext = pipeline.context(timeoutHandler);
            EventExecutor executor = handlerContext.executor();

            // Since, we are calling the handler directly, we need to make sure, it is in the owner eventloop, else it
            // can get concurrent callbacks.
            if (executor.inEventLoop()) {
                disableHandler(timeoutHandler, handlerContext);
View Full Code Here

                    ChannelHandler timeoutHandler = ctx.pipeline().get(READ_TIMEOUT_HANDLER_NAME);
                    if (null == timeoutHandler) {
                        ctx.pipeline().addFirst(READ_TIMEOUT_HANDLER_NAME, new ReadTimeoutHandler(timeout, timeUnit));
                    } else {
                        // This will always be invoked from the eventloop as it is a future listener callback.
                        ChannelHandlerContext handlerContext = ctx.pipeline().context(timeoutHandler);
                        timeoutHandler.handlerAdded(handlerContext);
                    }
                }
            });
            super.write(ctx, msg, promise);
View Full Code Here

     * <b>This must only be called before passing the connection instance to any other code.</b> The reason why this is
     * not done as part of the constructor is that {@link NewRxConnectionEvent} requires the {@link ObservableConnection}
     * instance which when sending from the constructor will escape "this"
     */
    protected void fireNewRxConnectionEvent() {
        ChannelHandlerContext firstContext = getChannel().pipeline().firstContext();
        firstContext.fireUserEventTriggered(new NewRxConnectionEvent(this, inputSubject));
    }
View Full Code Here

        }

        @Override
        public Observable<Void> handle(final ObservableConnection<I, O> connection) {
            final ChannelPipeline p = connection.getChannel().pipeline();
            ChannelHandlerContext hctx = p.context(WebSocketServerHandler.class);
            if (hctx != null) {
                WebSocketServerHandler handler = p.get(WebSocketServerHandler.class);
                final PublishSubject<Void> subject = PublishSubject.create();
                handler.addHandshakeFinishedListener(new ChannelFutureListener() {
                    @Override
View Full Code Here

                }

                @Override
                public void onNext(final ObservableConnection<T, T> connection) {
                    final ChannelPipeline p = connection.getChannel().pipeline();
                    ChannelHandlerContext hctx = p.context(WebSocketClientHandler.class);
                    if (hctx != null) {
                        WebSocketClientHandler handler = p.get(WebSocketClientHandler.class);
                        handler.addHandshakeFinishedListener(new ChannelFutureListener() {
                            @Override
                            public void operationComplete(ChannelFuture future) throws Exception {
View Full Code Here

        }
    }

    private void updatePipeline(ChannelHandlerContext ctx) {
        ChannelPipeline p = ctx.pipeline();
        ChannelHandlerContext nettyEncoderCtx = p.context(WebSocketFrameEncoder.class);
        p.addAfter(nettyEncoderCtx.name(), "websocket-write-metrics", new ServerWriteMetricsHandler(eventsSubject));
        ChannelHandlerContext nettyDecoderCtx = p.context(WebSocketFrameDecoder.class);
        p.addAfter(nettyDecoderCtx.name(), "websocket-read-metrics", new ServerReadMetricsHandler(eventsSubject));
        if (messageAggregator) {
            p.addAfter("websocket-read-metrics", "websocket-frame-aggregator", new WebSocketFrameAggregator(maxFramePayloadLength));
        }
        p.remove(this);
    }
View Full Code Here

TOP

Related Classes of io.netty.channel.ChannelHandlerContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.