better network structure
Some checks failed
Linux arm64 / Build (push) Has been cancelled

This commit is contained in:
2025-01-23 22:24:23 +01:00
parent 5e99cd92df
commit bfe98a2cf0
22 changed files with 248 additions and 93 deletions

View File

@@ -0,0 +1,36 @@
package network.server;
import java.io.IOException;
import java.net.Socket;
public class ServerAcceptThread extends Thread {
private final Server server;
public ServerAcceptThread(Server server) {
this.server = server;
}
public void cancel() {
try {
this.server.serverSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
interrupt();
}
@Override
public void run() {
try {
while(!interrupted()) {
Socket newConnection = this.server.serverSocket.accept();
ServerConnexion serverConnection = new ServerConnexion(newConnection, this.server);
this.server.connexions.add(serverConnection);
}
} catch(IOException e) {
// e.printStackTrace();
}
}
}