Fix: RMI Reconnection system

This commit is contained in:
rubenpirreram
2026-05-10 19:13:18 +02:00
parent 670afb40a8
commit 6491eb3a85
2 changed files with 3 additions and 12 deletions
@@ -99,14 +99,7 @@ public class RMIHeartbeat {
// Remove RMI callback so notifyAll skips this client
clients.remove(username);
// If it was this player's turn, skip it
Game snapshot = this.game;
if (snapshot != null &&
snapshot.getCurrentState().getCurrentPlayer().getUserName().equals(username)) {
actionQueue.add(new DisconnectedPlayer(username));
}
actionQueue.add(new DisconnectedPlayer(username));
System.out.println("RMI disconnected: " + username);
}
}
@@ -70,7 +70,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
throws RemoteException {
if (preferredInt < 2 || preferredInt > 5) return false;
//synchronized (controller) {
synchronized (controller) {
if (playerList.isEmpty()) {
model = new Game(preferredInt);
controller.setModel(model);
@@ -92,12 +92,10 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
callback.onGameInit(model);
System.out.println("Model sent: " + username);
actionQueue.add(new ReconnectPlayer(username));
return true;
}
return false;
//}
}
}
// -------------------------------------------------------------------------