Add proper async player disconnections

Blocking can cause performance problems
This commit is contained in:
Spottedleaf
2024-10-16 06:41:32 -07:00
parent e95dccb515
commit 7ec2cf09a3
3 changed files with 63 additions and 25 deletions

View File

@@ -269,7 +269,22 @@
public void write(ChannelHandlerContext channelhandlercontext, Object object, ChannelPromise channelpromise) throws Exception {
super.write(channelhandlercontext, object, channelpromise);
}
@@ -633,6 +763,7 @@
@@ -613,6 +743,14 @@
}
+ // Paper start - add proper async disconnect
+ public void enableAutoRead() {
+ if (this.channel != null) {
+ this.channel.config().setAutoRead(true);
+ }
+ }
+ // Paper end - add proper async disconnect
+
public void setupCompression(int compressionThreshold, boolean rejectsBadPackets) {
if (compressionThreshold >= 0) {
ChannelHandler channelhandler = this.channel.pipeline().get("decompress");
@@ -633,6 +771,7 @@
} else {
this.channel.pipeline().addAfter("prepender", "compress", new CompressionEncoder(compressionThreshold));
}
@@ -277,7 +292,7 @@
} else {
if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) {
this.channel.pipeline().remove("decompress");
@@ -641,6 +772,7 @@
@@ -641,6 +780,7 @@
if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) {
this.channel.pipeline().remove("compress");
}
@@ -285,7 +300,7 @@
}
}
@@ -661,6 +793,27 @@
@@ -661,6 +801,27 @@
packetlistener1.onDisconnect(disconnectiondetails);
}