Run closeWith() logic in the event loop

This commit is contained in:
Andrew Steinborn
2020-06-04 01:35:32 -04:00
parent ee4bae60a9
commit 456b4b217f

View File

@@ -205,8 +205,10 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
*/
public void closeWith(Object msg) {
if (channel.isActive()) {
knownDisconnect = true;
channel.writeAndFlush(msg).addListener(ChannelFutureListener.CLOSE);
channel.eventLoop().execute(() -> {
knownDisconnect = true;
channel.writeAndFlush(msg).addListener(ChannelFutureListener.CLOSE);
});
}
}