Fixed bug where server could connect to an expired server

- Increased update interval

Tags: #story[1281]
This commit is contained in:
Michael Rausch
2017-09-28 15:00:00 +13:00
parent 3345734efd
commit 80c26a9e4a
7 changed files with 25 additions and 13 deletions
@@ -95,7 +95,7 @@ public class GameClient {
* @param ipAddress IP to connect to.
* @param portNumber Port to connect to.
*/
public void runAsClient(String ipAddress, Integer portNumber) {
public boolean runAsClient(String ipAddress, Integer portNumber) {
try {
startClientToServerThread(ipAddress, portNumber);
socketThread.addDisconnectionListener((cause) -> {
@@ -106,12 +106,19 @@ public class GameClient {
ViewManager.getInstance().setPlayerList(clientLobbyList);
while (regattaData == null){
int triesLeft = 10;
while (regattaData == null && triesLeft >= 0){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InterruptedException ignored) {
;
}
triesLeft--;
}
if (triesLeft < 1){
return false;
}
ViewManager.getInstance().setProperty("serverName", regattaData.getRegattaName());
@@ -127,6 +134,8 @@ public class GameClient {
} catch (IOException ioe) {
ViewManager.getInstance().showErrorSnackBar("There are no servers currently available.");
}
return true;
}
private void destroyClientToServerThread() {