network: process time out
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user