Check method moved to new class called ping so that refresh will be called on new thread.

#story[1087]
This commit is contained in:
zwu18
2017-07-26 21:59:43 +12:00
parent 243c450790
commit 53a01402e1
4 changed files with 67 additions and 22 deletions
@@ -48,10 +48,13 @@ public class LobbyController extends Controller {
statusColumn.setCellValueFactory(cellData -> cellData.getValue().statusProperty());
lobbyTable.getSelectionModel().selectedItemProperty().addListener((obs, prev, curr) -> {
if (curr != null && ((RaceConnection)curr).check())
{joinGameBtn.setDisable(false);}
else {joinGameBtn.setDisable(true);}
if (curr != null && curr.statusProperty().getValue().equals("Ready")) {
joinGameBtn.setDisable(false);
}
else {
joinGameBtn.setDisable(true);
System.out.println(curr.statusProperty().getValue());
}
});
joinGameBtn.setDisable(true);
}
@@ -60,6 +63,14 @@ public class LobbyController extends Controller {
for(RaceConnection connection: connections) {
connection.check();
}
try {
if (lobbyTable.getSelectionModel().getSelectedItem().statusProperty().getValue().equals("Ready")) {
joinGameBtn.setDisable(false);
} else {
joinGameBtn.setDisable(true);
}
} catch (Exception e){}
}
public void connectSocket() {
@@ -68,7 +79,9 @@ public class LobbyController extends Controller {
Socket socket = new Socket(connection.getHostname(), connection.getPort());
lobbyWrapper.setVisible(false);
parent.enterLobby(socket);
} catch (IOException e) { /* Never reached */ }
} catch (IOException e) { /* Never reached */
e.printStackTrace();
}
}
public AnchorPane startWrapper(){