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,
|
Blank,
|
||||||
Ready,
|
Ready,
|
||||||
Assigned,
|
Assigned,
|
||||||
Playing
|
Reconnect, Playing
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,13 @@ public class UserManager {
|
|||||||
Logger.trace("forwarding message to the LobbyManager");
|
Logger.trace("forwarding message to the LobbyManager");
|
||||||
AtomicBoolean running = new AtomicBoolean(false);
|
AtomicBoolean running = new AtomicBoolean(false);
|
||||||
if(LobbyManager.getInstance().handleConnect(client, running)) {
|
if(LobbyManager.getInstance().handleConnect(client, running)) {
|
||||||
client.state = ClientState.Ready;
|
|
||||||
|
var clientHasRunningGame = running.get();
|
||||||
|
if (clientHasRunningGame) {
|
||||||
|
client.state = ClientState.Reconnect;
|
||||||
|
} else {
|
||||||
|
client.state = ClientState.Ready;
|
||||||
|
}
|
||||||
|
|
||||||
HelloClientMessage response = new HelloClientMessage();
|
HelloClientMessage response = new HelloClientMessage();
|
||||||
response.runningGame = running.get();
|
response.runningGame = running.get();
|
||||||
@ -164,8 +170,8 @@ public class UserManager {
|
|||||||
|
|
||||||
/** Handles a reconnectMessage, and reconnects the client if needed */
|
/** Handles a reconnectMessage, and reconnects the client if needed */
|
||||||
private void handleReconnectMessage(Client client, ReconnectMessage message) {
|
private void handleReconnectMessage(Client client, ReconnectMessage message) {
|
||||||
if(client.state != ClientState.Ready) {
|
if(client.state != ClientState.Reconnect) {
|
||||||
client.sendError("Invalid message.");
|
client.sendError("Invalid message, as client is not in reconnect-ready state");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,8 +185,8 @@ public class UserManager {
|
|||||||
client.sendError("You could not be reconnected to the Lobby");
|
client.sendError("You could not be reconnected to the Lobby");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger.trace("No reconnect requested, changing ClientState to blank");
|
Logger.trace("No reconnect requested, setting client to ready to connect state");
|
||||||
client.state = ClientState.Blank;
|
client.state = ClientState.Ready;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user