mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Ensure channel is set before returning from bind().
This commit is contained in:
parent
ce140f43d6
commit
9c1ac6aa9b
1 changed files with 17 additions and 12 deletions
|
@ -87,24 +87,29 @@ public class TcpConnectionListener implements ConnectionListener {
|
||||||
|
|
||||||
server.addSession(session);
|
server.addSession(session);
|
||||||
}
|
}
|
||||||
}).group(this.group).localAddress(this.host, this.port).bind().addListener(new ChannelFutureListener() {
|
}).group(this.group).localAddress(this.host, this.port).bind();
|
||||||
@Override
|
|
||||||
public void operationComplete(ChannelFuture channelFuture) throws Exception {
|
|
||||||
if(channelFuture.isSuccess()) {
|
|
||||||
channel = channelFuture.channel();
|
|
||||||
callback.run();
|
|
||||||
} else if(channelFuture.cause() != null && !wait) {
|
|
||||||
System.err.println("[ERROR] Failed to asynchronously bind connection listener.");
|
|
||||||
channelFuture.cause().printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(wait) {
|
if(wait) {
|
||||||
try {
|
try {
|
||||||
future.sync();
|
future.sync();
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channel = future.channel();
|
||||||
|
callback.run();
|
||||||
|
} else {
|
||||||
|
future.addListener(new ChannelFutureListener() {
|
||||||
|
@Override
|
||||||
|
public void operationComplete(ChannelFuture channelFuture) throws Exception {
|
||||||
|
if(channelFuture.isSuccess()) {
|
||||||
|
channel = channelFuture.channel();
|
||||||
|
callback.run();
|
||||||
|
} else if(channelFuture.cause() != null && !wait) {
|
||||||
|
System.err.println("[ERROR] Failed to asynchronously bind connection listener.");
|
||||||
|
channelFuture.cause().printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue