Search in sources :

Example 86 with Future

use of org.apache.flink.shaded.netty4.io.netty.util.concurrent.Future in project spring-boot-protocol by wangzihaogithub.

the class NettyHttp2ClientPool method close.

@Override
public void close() {
    for (List<NettyHttp2Client> clients : values()) {
        for (NettyHttp2Client client : clients) {
            client.close().addListener(new GenericFutureListener<Future<? super Long>>() {

                @Override
                public void operationComplete(Future<? super Long> future) throws Exception {
                    LoggerFactoryX.getLogger(NettyHttp2ClientPool.class).info("http2 client close = {}", client.getRemoteAddress());
                }
            });
        }
    }
    clear();
    EventLoopGroup worker = this.worker;
    if (worker != null && !worker.isShutdown()) {
        worker.shutdownGracefully();
    }
}
Also used : EventLoopGroup(io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) Future(io.netty.util.concurrent.Future) UnknownHostException(java.net.UnknownHostException) SSLException(javax.net.ssl.SSLException)

Example 87 with Future

use of org.apache.flink.shaded.netty4.io.netty.util.concurrent.Future in project SMSGate by Lihuanghe.

the class SMPPSessionLoginManager method failedLogin.

@Override
protected void failedLogin(ChannelHandlerContext ctx, Object msg, long status) {
    if (msg instanceof BaseBind) {
        logger.error("Connected error status :{},msg : {}", status, msg);
        BaseBind message = (BaseBind) msg;
        // 认证失败
        PduResponse resp = message.createResponse();
        resp.setCommandStatus((int) SmppConstants.STATUS_BINDFAIL);
        ChannelFuture promise = ctx.writeAndFlush(resp);
        final ChannelHandlerContext finalctx = ctx;
        promise.addListener(new GenericFutureListener() {

            public void operationComplete(Future future) throws Exception {
                finalctx.close();
            }
        });
    } else {
        logger.error("connect msg type error : {}", msg);
        ctx.close();
    }
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) PduResponse(com.zx.sms.codec.smpp.msg.PduResponse) BaseBind(com.zx.sms.codec.smpp.msg.BaseBind) ChannelFuture(io.netty.channel.ChannelFuture) Future(io.netty.util.concurrent.Future) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) TlvConvertException(com.zx.sms.codec.smpp.TlvConvertException)

Example 88 with Future

use of org.apache.flink.shaded.netty4.io.netty.util.concurrent.Future in project SMSGate by Lihuanghe.

the class SgipUnbindRequestMessageHandler method channelRead0.

@Override
protected void channelRead0(final ChannelHandlerContext ctx, SgipUnbindRequestMessage msg) throws Exception {
    SgipUnbindResponseMessage resp = new SgipUnbindResponseMessage(msg.getHeader());
    ChannelFuture future = ctx.channel().writeAndFlush(resp);
    final ChannelHandlerContext finalctx = ctx;
    future.addListeners(new GenericFutureListener() {

        @Override
        public void operationComplete(Future future) throws Exception {
            ctx.executor().schedule(new Runnable() {

                @Override
                public void run() {
                    finalctx.channel().close();
                }
            }, 500, TimeUnit.MILLISECONDS);
        }
    });
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) Future(io.netty.util.concurrent.Future) ChannelFuture(io.netty.channel.ChannelFuture) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) SgipUnbindResponseMessage(com.zx.sms.codec.sgip12.msg.SgipUnbindResponseMessage)

Example 89 with Future

use of org.apache.flink.shaded.netty4.io.netty.util.concurrent.Future in project SMSGate by Lihuanghe.

the class UnbindMessageHandler method channelRead0.

@Override
protected void channelRead0(final ChannelHandlerContext ctx, Unbind msg) throws Exception {
    UnbindResp resp = msg.createResponse();
    ChannelFuture future = ctx.channel().writeAndFlush(resp);
    final ChannelHandlerContext finalctx = ctx;
    future.addListeners(new GenericFutureListener() {

        @Override
        public void operationComplete(Future future) throws Exception {
            ctx.executor().schedule(new Runnable() {

                @Override
                public void run() {
                    finalctx.channel().close();
                }
            }, 500, TimeUnit.MILLISECONDS);
        }
    });
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) Future(io.netty.util.concurrent.Future) ChannelFuture(io.netty.channel.ChannelFuture) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) UnbindResp(com.zx.sms.codec.smpp.msg.UnbindResp)

Example 90 with Future

use of org.apache.flink.shaded.netty4.io.netty.util.concurrent.Future in project WindSpigot by Wind-Development.

the class PlayerConnection method disconnect.

// No called of force closed
public void disconnect(String s) {
    // CraftBukkit start - fire PlayerKickEvent
    String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game.";
    PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);
    if (this.server.getServer().isRunning()) {
        this.server.getPluginManager().callEvent(event);
    }
    if (event.isCancelled()) {
        // Do not kick the player
        return;
    }
    // Send the possibly modified leave message
    s = event.getReason();
    // CraftBukkit end
    final ChatComponentText chatcomponenttext = new ChatComponentText(s);
    this.networkManager.a(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() {

        @Override
        public void operationComplete(Future future) throws Exception {
            // CraftBukkit - fix decompile error
            PlayerConnection.this.networkManager.close(chatcomponenttext);
        }
    }, new GenericFutureListener[0]);
    // CraftBukkit - fire quit instantly
    this.a(chatcomponenttext);
    this.networkManager.k();
    // CraftBukkit - Don't wait
    this.minecraftServer.postToMainThread(new Runnable() {

        @Override
        public void run() {
            PlayerConnection.this.networkManager.l();
        }
    });
}
Also used : Future(io.netty.util.concurrent.Future) PlayerKickEvent(org.bukkit.event.player.PlayerKickEvent) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Future (io.netty.util.concurrent.Future)177 Channel (io.netty.channel.Channel)61 ChannelFuture (io.netty.channel.ChannelFuture)58 InetSocketAddress (java.net.InetSocketAddress)45 ArrayList (java.util.ArrayList)45 IOException (java.io.IOException)44 GenericFutureListener (io.netty.util.concurrent.GenericFutureListener)42 CompletableFuture (java.util.concurrent.CompletableFuture)40 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)35 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)34 List (java.util.List)34 ChannelFutureListener (io.netty.channel.ChannelFutureListener)31 EventLoopGroup (io.netty.channel.EventLoopGroup)30 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)30 FutureListener (io.netty.util.concurrent.FutureListener)28 Logger (org.slf4j.Logger)28 LoggerFactory (org.slf4j.LoggerFactory)28 TimeUnit (java.util.concurrent.TimeUnit)27 Bootstrap (io.netty.bootstrap.Bootstrap)25 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)25