fix: fixed bug where sending reoconnect while not able to do so breaks the server
This commit is contained in:
parent
8d26c3f2ea
commit
3c49c5bbd8
@ -4,5 +4,5 @@ public enum ClientState {
|
||||
Blank,
|
||||
Ready,
|
||||
Assigned,
|
||||
Playing
|
||||
Reconnect, Playing
|
||||
}
|
||||
|
@ -152,7 +152,13 @@ public class UserManager {
|
||||
Logger.trace("forwarding message to the LobbyManager");
|
||||
AtomicBoolean running = new AtomicBoolean(false);
|
||||
if(LobbyManager.getInstance().handleConnect(client, running)) {
|
||||
|
||||
var clientHasRunningGame = running.get();
|
||||
if (clientHasRunningGame) {
|
||||
client.state = ClientState.Reconnect;
|
||||
} else {
|
||||
client.state = ClientState.Ready;
|
||||
}
|
||||
|
||||
HelloClientMessage response = new HelloClientMessage();
|
||||
response.runningGame = running.get();
|
||||
@ -164,8 +170,8 @@ public class UserManager {
|
||||
|
||||
/** Handles a reconnectMessage, and reconnects the client if needed */
|
||||
private void handleReconnectMessage(Client client, ReconnectMessage message) {
|
||||
if(client.state != ClientState.Ready) {
|
||||
client.sendError("Invalid message.");
|
||||
if(client.state != ClientState.Reconnect) {
|
||||
client.sendError("Invalid message, as client is not in reconnect-ready state");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -179,8 +185,8 @@ public class UserManager {
|
||||
client.sendError("You could not be reconnected to the Lobby");
|
||||
}
|
||||
} else {
|
||||
Logger.trace("No reconnect requested, changing ClientState to blank");
|
||||
client.state = ClientState.Blank;
|
||||
Logger.trace("No reconnect requested, setting client to ready to connect state");
|
||||
client.state = ClientState.Ready;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user