use of io.netty.util.concurrent.GenericFutureListener 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();
}
}
use of io.netty.util.concurrent.GenericFutureListener 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);
}
});
}
use of io.netty.util.concurrent.GenericFutureListener 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);
}
});
}
use of io.netty.util.concurrent.GenericFutureListener 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();
}
});
}
use of io.netty.util.concurrent.GenericFutureListener in project PaperDev by Kamillaova.
the class ServerConnection method c.
public void c() {
List list = this.h;
synchronized (this.h) {
// Spigot Start
// Paper
addPending();
// This prevents players from 'gaming' the server, and strategically relogging to increase their position in the tick order
if (org.spigotmc.SpigotConfig.playerShuffle > 0 && MinecraftServer.currentTick % org.spigotmc.SpigotConfig.playerShuffle == 0) {
Collections.shuffle(this.h);
}
// Spigot End
Iterator iterator = this.h.iterator();
while (iterator.hasNext()) {
final NetworkManager networkmanager = (NetworkManager) iterator.next();
if (!networkmanager.h()) {
if (networkmanager.isConnected()) {
try {
networkmanager.a();
} catch (Exception exception) {
if (networkmanager.isLocal()) {
CrashReport crashreport = CrashReport.a(exception, "Ticking memory connection");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Ticking connection");
crashreportsystemdetails.a("Connection", new CrashReportCallable() {
public String a() throws Exception {
return networkmanager.toString();
}
public Object call() throws Exception {
return this.a();
}
});
throw new ReportedException(crashreport);
}
ServerConnection.e.warn("Failed to handle packet for {}", networkmanager.getSocketAddress(), exception);
final ChatComponentText chatcomponenttext = new ChatComponentText("Internal server error");
networkmanager.sendPacket(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() {
public void operationComplete(Future future) throws Exception {
networkmanager.close(chatcomponenttext);
}
}, new GenericFutureListener[0]);
networkmanager.stopReading();
}
} else {
// Fix a race condition where a NetworkManager could be unregistered just before connection.
if (networkmanager.preparing)
continue;
// Spigot End
iterator.remove();
networkmanager.handleDisconnection();
}
}
}
}
}
Aggregations