use of de.dytanic.cloudnetcore.api.event.network.WrapperChannelDisconnectEvent in project CloudNet by Dytanic.
the class CloudNetClient method channelInactive.
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
if ((!channel.isActive() || !channel.isOpen() || !channel.isWritable())) {
System.out.println("Channel disconnected [" + channel.remoteAddress().toString() + "/serverId=" + networkComponent.getServerId() + "]");
ctx.close().syncUninterruptibly();
if (networkComponent instanceof MinecraftServer) {
((MinecraftServer) networkComponent).setChannelLostTime(System.currentTimeMillis());
}
if (networkComponent instanceof ProxyServer) {
((ProxyServer) networkComponent).setChannelLostTime(System.currentTimeMillis());
}
if (networkComponent instanceof Wrapper) {
try {
((Wrapper) networkComponent).disconnct();
} catch (Exception ex) {
((Wrapper) networkComponent).getServers().clear();
((Wrapper) networkComponent).getProxys().clear();
}
CloudNet.getInstance().getEventManager().callEvent(new WrapperChannelDisconnectEvent(((Wrapper) networkComponent)));
}
networkComponent.setChannel(null);
}
}
Aggregations