Package io.netty.channel

Examples of io.netty.channel.ChannelFutureListener


    public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
        if (msg instanceof FullHttpRequest) {
            ChannelFuture upgradeFuture = handleHttpRequest(ctx, (FullHttpRequest) msg);
            if (upgradeFuture != null) {
                updatePipeline(ctx);
                upgradeFuture.addListener(new ChannelFutureListener() {
                    @Override
                    public void operationComplete(ChannelFuture future) throws Exception {
                        if (future.isSuccess()) {
                            handshakeFuture.setSuccess();
                            eventsSubject.onEvent(WebSocketServerMetricsEvent.HANDSHAKE_PROCESSED);
View Full Code Here


          handshaker = wsFactory.newHandshaker(req);
          // Check if we can find the right handshaker for the requested version
          if (handshaker == null) {
              WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel());
          } else {
              handshaker.handshake(ctx.channel(), req).addListener(new ChannelFutureListener() {
                  @Override
                  public void operationComplete(ChannelFuture future) throws Exception {
                      if(!future.isSuccess()) {
                          // Handshake failed with an Exception, forward it to the other handlers in the chain
                          future.channel().pipeline().fireExceptionCaught(future.cause());
View Full Code Here

     * Note: method does not block
     */
    public void start() {
        if (channelFuture == null) {
            channelFuture = bootstrap.bind();
            channelFuture.addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    future.channel().closeFuture().addListener(new ChannelFutureListener() {
                        @Override
                        public void operationComplete(ChannelFuture future) throws Exception {
                            bossGroup.shutdownGracefully();
                            workerGroup.shutdownGracefully();
                        }
View Full Code Here

     */
    public void stop() {
        if (channelFuture == null) {
            throw new IllegalStateException("Server has not been started");
        }
        channelFuture.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                future.channel().close();
            }
        });
View Full Code Here

     * Note: method does not block
     */
    public void start() {
        if (channelFuture == null) {
            channelFuture = bootstrap.connect();
            channelFuture.addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    future.channel().closeFuture().addListener(new ChannelFutureListener() {
                        @Override
                        public void operationComplete(ChannelFuture future) throws Exception {
                            workerGroup.shutdownGracefully();
                        }
                    });
View Full Code Here

     */
    public void stop() {
        if (channelFuture == null) {
            throw new IllegalStateException("Client has not been started");
        }
        channelFuture.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                future.channel().close();
            }
        });
View Full Code Here

        } else {
            timeoutFuture = null;
        }

        // Close the connection if close_notify is sent in time.
        flushFuture.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture f)
                    throws Exception {
                if (timeoutFuture != null) {
                    timeoutFuture.cancel(false);
View Full Code Here

                    }
                }
            }, timeoutMillis, TimeUnit.MILLISECONDS);

            // Cancel the scheduled timeout if the flush future is complete.
            future.addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    sf.cancel(false);
                }
            });
View Full Code Here

    }

    @Override

    public void flush(final ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
        promise.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                lastWriteTime = System.currentTimeMillis();
                firstWriterIdleEvent = firstAllIdleEvent = true;
            }
View Full Code Here

        ctx.deregister(promise);
    }

    @Override
    public void sendFile(ChannelHandlerContext ctx, FileRegion region, ChannelPromise promise) throws Exception {
        promise.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                lastWriteTime = System.currentTimeMillis();
                firstWriterIdleEvent = firstAllIdleEvent = true;
            }
View Full Code Here

TOP

Related Classes of io.netty.channel.ChannelFutureListener

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.