Fix: RMI Reconnection system
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
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;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user