mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Fixed bug where server could connect to an expired server
- Increased update interval Tags: #story[1281]
This commit is contained in:
@@ -105,7 +105,6 @@ public class App extends Application {
|
|||||||
}
|
}
|
||||||
}, 0, 1200);
|
}, 0, 1200);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
parseArgs(args);
|
parseArgs(args);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class DiscoveryServer {
|
|||||||
" .:;...'cxxxxxxxxxxxxoc;,::,..cdl;;l' \n" +
|
" .:;...'cxxxxxxxxxxxxoc;,::,..cdl;;l' \n" +
|
||||||
" .cl;':,'';oxxxxxxdxxxxxx:....,cooc,cO; \n" +
|
" .cl;':,'';oxxxxxxdxxxxxx:....,cooc,cO; \n" +
|
||||||
" .,,,::;,lxoc:,,:lxxxxxxxxxxxo:,,;lxxl;'oNc \n" +
|
" .,,,::;,lxoc:,,:lxxxxxxxxxxxo:,,;lxxl;'oNc \n" +
|
||||||
" .cdxo;':lxxxxxxc'';cccccoxxxxxxxxxxxxo,.;lc. " + ANSI_YELLOW + "Party-Parrots-At-Sea Discovery Server v0.1 " + selectedColor +"\n" +
|
" .cdxo;':lxxxxxxc'';cccccoxxxxxxxxxxxxo,.;lc. " + ANSI_YELLOW + "Party-Parrots-At-Sea Discovery Server v1.0.0 (Release) " + selectedColor +"\n" +
|
||||||
" .loc'.'lxxxxxxxxocc;''''';ccoxxxxxxxxx:..oc \n" +
|
" .loc'.'lxxxxxxxxocc;''''';ccoxxxxxxxxx:..oc \n" +
|
||||||
"olc,..',:cccccccccccc:;;;;;;;;:ccccccccc,.'c, \n" +
|
"olc,..',:cccccccccccc:;;;;;;;;:ccccccccc,.'c, \n" +
|
||||||
"Ol;......................................;l' ");
|
"Ol;......................................;l' ");
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import java.util.Timer;
|
|||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class DiscoveryServerClient {
|
public class DiscoveryServerClient {
|
||||||
private final Integer UPDATE_INTERVAL_MS = 5000;
|
private final Integer UPDATE_INTERVAL_MS = 1000;
|
||||||
|
|
||||||
private static String roomCode = null;
|
private static String roomCode = null;
|
||||||
private Timer serverListingUpdateTimer;
|
private Timer serverListingUpdateTimer;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package seng302.discoveryServer.util;
|
package seng302.discoveryServer.util;
|
||||||
|
|
||||||
public class ServerListing {
|
public class ServerListing {
|
||||||
public final static int SERVER_TTL_DEFAULT = 10;
|
public final static int SERVER_TTL_DEFAULT = 3;
|
||||||
|
|
||||||
private String serverName = "";
|
private String serverName = "";
|
||||||
private String mapName = "";
|
private String mapName = "";
|
||||||
|
|||||||
@@ -180,10 +180,12 @@ public class ClientToServerThread implements Runnable {
|
|||||||
notifyDisconnectListeners("Connection to server was terminated");
|
notifyDisconnectListeners("Connection to server was terminated");
|
||||||
closeSocket();
|
closeSocket();
|
||||||
|
|
||||||
Platform.runLater(() -> {
|
//thread.interrupt();
|
||||||
ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
|
|
||||||
ViewManager.getInstance().goToStartView();
|
// Platform.runLater(() -> {
|
||||||
});
|
// ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
|
||||||
|
// ViewManager.getInstance().goToStartView();
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendCustomizationRequest(CustomizeRequestType reqType, byte[] payload) {
|
public void sendCustomizationRequest(CustomizeRequestType reqType, byte[] payload) {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class GameClient {
|
|||||||
* @param ipAddress IP to connect to.
|
* @param ipAddress IP to connect to.
|
||||||
* @param portNumber Port to connect to.
|
* @param portNumber Port to connect to.
|
||||||
*/
|
*/
|
||||||
public void runAsClient(String ipAddress, Integer portNumber) {
|
public boolean runAsClient(String ipAddress, Integer portNumber) {
|
||||||
try {
|
try {
|
||||||
startClientToServerThread(ipAddress, portNumber);
|
startClientToServerThread(ipAddress, portNumber);
|
||||||
socketThread.addDisconnectionListener((cause) -> {
|
socketThread.addDisconnectionListener((cause) -> {
|
||||||
@@ -106,12 +106,19 @@ public class GameClient {
|
|||||||
|
|
||||||
ViewManager.getInstance().setPlayerList(clientLobbyList);
|
ViewManager.getInstance().setPlayerList(clientLobbyList);
|
||||||
|
|
||||||
while (regattaData == null){
|
int triesLeft = 10;
|
||||||
|
|
||||||
|
while (regattaData == null && triesLeft >= 0){
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException ignored) {
|
||||||
e.printStackTrace();
|
;
|
||||||
}
|
}
|
||||||
|
triesLeft--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (triesLeft < 1){
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewManager.getInstance().setProperty("serverName", regattaData.getRegattaName());
|
ViewManager.getInstance().setProperty("serverName", regattaData.getRegattaName());
|
||||||
@@ -127,6 +134,8 @@ public class GameClient {
|
|||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ViewManager.getInstance().showErrorSnackBar("There are no servers currently available.");
|
ViewManager.getInstance().showErrorSnackBar("There are no servers currently available.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroyClientToServerThread() {
|
private void destroyClientToServerThread() {
|
||||||
|
|||||||
@@ -140,7 +140,9 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewManager.getInstance().getGameClient().runAsClient(listing.getAddress(), listing.getPortNumber());
|
if (!ViewManager.getInstance().getGameClient().runAsClient(listing.getAddress(), listing.getPortNumber())){
|
||||||
|
ViewManager.getInstance().showErrorSnackBar("Could not connect to server");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user