Improve socket shutdown

This commit is contained in:
TheMode 2021-08-04 05:15:40 +02:00
parent 557d34c378
commit 8895e49a52
3 changed files with 3 additions and 3 deletions

View File

@ -65,6 +65,7 @@ public class Server {
public void stop() {
this.stop = true;
this.workers.forEach(worker -> worker.selector.wakeup());
}
public String getAddress() {

View File

@ -19,7 +19,7 @@ import java.util.zip.Inflater;
public class Worker {
private final Map<SocketChannel, NettyPlayerConnection> connectionMap = new ConcurrentHashMap<>();
private final Selector selector = Selector.open();
protected final Selector selector = Selector.open();
private final PacketProcessor packetProcessor;
public Worker(Server server, PacketProcessor packetProcessor) throws IOException {

View File

@ -101,8 +101,7 @@ public final class PacketUtils {
continue;
final PlayerConnection playerConnection = player.getPlayerConnection();
if (playerConnection instanceof NettyPlayerConnection) {
final NettyPlayerConnection nettyPlayerConnection = (NettyPlayerConnection) playerConnection;
nettyPlayerConnection.write(framedPacket);
((NettyPlayerConnection) playerConnection).write(framedPacket);
} else {
playerConnection.sendPacket(packet);
}