network: process time out

This commit is contained in:
2025-03-06 12:02:42 +01:00
parent 72c62bb1b4
commit 462307dabc
4 changed files with 31 additions and 9 deletions

View File

@@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.List;
import network.protocol.Packet;
import utilities.Signal;
public class Socket {
private final DatagramSocket socket;
@@ -20,6 +21,8 @@ public class Socket {
private final Thread readThread;
private final PacketPool packetPool;
public final Signal onClose = new Signal();
public Socket() throws SocketException {
this.socket = new DatagramSocket();
this.handlers = new ArrayList<>();
@@ -86,6 +89,8 @@ public class Socket {
public void close() {
this.socket.close();
this.packetPool.close();
this.readThread.interrupt();
this.onClose.emit();
}
void handlePacket(Packet packet, InetSocketAddress address) {