Terminating client thread before server thread to prevent alert box popping up

This commit is contained in:
Zhi You Tan
2017-08-14 11:21:33 +12:00
parent 9b7f4a93d8
commit c77adf385e
2 changed files with 7 additions and 9 deletions
@@ -157,14 +157,12 @@ public class ClientToServerThread implements Runnable {
} catch (ByteReadException e) {
e.printStackTrace();
closeSocket();
if (Platform.isFxApplicationThread()) {
Platform.runLater(() -> {
Alert alert = new Alert(AlertType.ERROR);
alert.setHeaderText("Host has disconnected");
alert.setContentText("Cannot find Server");
alert.showAndWait();
});
}
clientLog(e.getMessage(), 1);
return;
}
@@ -71,8 +71,8 @@ public class RegularPacketsTest {
@After
public void teardown () throws Exception {
serverThread.terminate();
clientThread.setSocketToClose();
serverThread.terminate();
GameState.setCurrentStage(GameStages.LOBBYING);
for (int i = 0; i<20; i++)
SleepThreadMaxDelay(); //Make sure socket is closed and toolkit remade.