Refactored code

This commit is contained in:
Bas de Jong
2025-10-06 23:10:07 +02:00
parent c6c1c110f7
commit 6d7a8e4c50
2 changed files with 9 additions and 4 deletions

View File

@@ -31,7 +31,9 @@ public final class ConnectedLayer extends Layer {
new EventFlow().addPostEvent(new NetworkEvents.SendLogin(this.clientId, this.user)).postEvent();
new EventFlow().listen(this::handleReceivedChallenge);
new Thread(this::populatePlayerList).start();
Thread popThread = new Thread(this::populatePlayerList);
popThread.setDaemon(false);
popThread.start();
reload();
}
@@ -57,7 +59,7 @@ public final class ConnectedLayer extends Layer {
};
Timer pollTimer = new Timer();
pollTimer.schedule(task, 0L, 5000L);
pollTimer.schedule(task, 0L, 5000L); // TODO: Block app exit, fix later
}
private void sendChallenge(String oppUsername, String gameType) {

View File

@@ -74,8 +74,11 @@ public final class TicTacToeLayer extends Layer {
.addPostEvent(NetworkEvents.StartClient.class,
information.serverIP(),
Integer.parseInt(information.serverPort()))
.onResponse(NetworkEvents.StartClientResponse.class, event ->
new Thread(() -> serverGameThread(event)).start())
.onResponse(NetworkEvents.StartClientResponse.class, event -> {
Thread a = new Thread(() -> serverGameThread(event));
a.setDaemon(false);
a.start();
})
.postEvent();
}