mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 02:44:50 +00:00
Refactored code
This commit is contained in:
@@ -31,7 +31,9 @@ public final class ConnectedLayer extends Layer {
|
|||||||
new EventFlow().addPostEvent(new NetworkEvents.SendLogin(this.clientId, this.user)).postEvent();
|
new EventFlow().addPostEvent(new NetworkEvents.SendLogin(this.clientId, this.user)).postEvent();
|
||||||
new EventFlow().listen(this::handleReceivedChallenge);
|
new EventFlow().listen(this::handleReceivedChallenge);
|
||||||
|
|
||||||
new Thread(this::populatePlayerList).start();
|
Thread popThread = new Thread(this::populatePlayerList);
|
||||||
|
popThread.setDaemon(false);
|
||||||
|
popThread.start();
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
@@ -57,7 +59,7 @@ public final class ConnectedLayer extends Layer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Timer pollTimer = new Timer();
|
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) {
|
private void sendChallenge(String oppUsername, String gameType) {
|
||||||
|
|||||||
@@ -74,8 +74,11 @@ public final class TicTacToeLayer extends Layer {
|
|||||||
.addPostEvent(NetworkEvents.StartClient.class,
|
.addPostEvent(NetworkEvents.StartClient.class,
|
||||||
information.serverIP(),
|
information.serverIP(),
|
||||||
Integer.parseInt(information.serverPort()))
|
Integer.parseInt(information.serverPort()))
|
||||||
.onResponse(NetworkEvents.StartClientResponse.class, event ->
|
.onResponse(NetworkEvents.StartClientResponse.class, event -> {
|
||||||
new Thread(() -> serverGameThread(event)).start())
|
Thread a = new Thread(() -> serverGameThread(event));
|
||||||
|
a.setDaemon(false);
|
||||||
|
a.start();
|
||||||
|
})
|
||||||
.postEvent();
|
.postEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user