mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 01:17:47 +01:00
Improve socket shutdown
This commit is contained in:
parent
557d34c378
commit
8895e49a52
@ -65,6 +65,7 @@ public class Server {
|
|||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
this.stop = true;
|
this.stop = true;
|
||||||
|
this.workers.forEach(worker -> worker.selector.wakeup());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
|
@ -19,7 +19,7 @@ import java.util.zip.Inflater;
|
|||||||
|
|
||||||
public class Worker {
|
public class Worker {
|
||||||
private final Map<SocketChannel, NettyPlayerConnection> connectionMap = new ConcurrentHashMap<>();
|
private final Map<SocketChannel, NettyPlayerConnection> connectionMap = new ConcurrentHashMap<>();
|
||||||
private final Selector selector = Selector.open();
|
protected final Selector selector = Selector.open();
|
||||||
private final PacketProcessor packetProcessor;
|
private final PacketProcessor packetProcessor;
|
||||||
|
|
||||||
public Worker(Server server, PacketProcessor packetProcessor) throws IOException {
|
public Worker(Server server, PacketProcessor packetProcessor) throws IOException {
|
||||||
|
@ -101,8 +101,7 @@ public final class PacketUtils {
|
|||||||
continue;
|
continue;
|
||||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||||
if (playerConnection instanceof NettyPlayerConnection) {
|
if (playerConnection instanceof NettyPlayerConnection) {
|
||||||
final NettyPlayerConnection nettyPlayerConnection = (NettyPlayerConnection) playerConnection;
|
((NettyPlayerConnection) playerConnection).write(framedPacket);
|
||||||
nettyPlayerConnection.write(framedPacket);
|
|
||||||
} else {
|
} else {
|
||||||
playerConnection.sendPacket(packet);
|
playerConnection.sendPacket(packet);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user