Fix: RMI Reconnection system
This commit is contained in:
@@ -99,14 +99,7 @@ public class RMIHeartbeat {
|
|||||||
|
|
||||||
// Remove RMI callback so notifyAll skips this client
|
// Remove RMI callback so notifyAll skips this client
|
||||||
clients.remove(username);
|
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);
|
System.out.println("RMI disconnected: " + username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
|||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
if (preferredInt < 2 || preferredInt > 5) return false;
|
if (preferredInt < 2 || preferredInt > 5) return false;
|
||||||
|
|
||||||
//synchronized (controller) {
|
synchronized (controller) {
|
||||||
if (playerList.isEmpty()) {
|
if (playerList.isEmpty()) {
|
||||||
model = new Game(preferredInt);
|
model = new Game(preferredInt);
|
||||||
controller.setModel(model);
|
controller.setModel(model);
|
||||||
@@ -92,12 +92,10 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
|||||||
callback.onGameInit(model);
|
callback.onGameInit(model);
|
||||||
System.out.println("Model sent: " + username);
|
System.out.println("Model sent: " + username);
|
||||||
actionQueue.add(new ReconnectPlayer(username));
|
actionQueue.add(new ReconnectPlayer(username));
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user