Partial implementation client resilience

This commit is contained in:
rubenpirreram
2026-05-07 21:17:00 +02:00
parent 7757b38155
commit e78096d2e0
10 changed files with 101 additions and 34 deletions
@@ -3,8 +3,10 @@ package it.polimi.ingsw.gc14;
import it.polimi.ingsw.gc14.Controller.GameController;
import it.polimi.ingsw.gc14.Model.Game;
import it.polimi.ingsw.gc14.Model.Player;
import it.polimi.ingsw.gc14.Network.ClientPlayer;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.Network.NetworkEvents.SkipPlayerDisconnected;
import it.polimi.ingsw.gc14.Network.RMI.Server.RMIServer;
import it.polimi.ingsw.gc14.Network.TCP.Server.TCPServer;
import it.polimi.ingsw.gc14.View.TUI.TUI;
@@ -85,13 +87,16 @@ public class ServerLauncher {
* @throws RemoteException if an RMI error occurs
*/
public boolean doFirstEvent() throws InterruptedException, RemoteException {
NetworkEvent event = actionQueue.take();
event.setIsError(!event.apply(gameController));
serverRMI.notifyAll(event);
serverTCP.notifyAll(event);
return !event.getIsError();
synchronized (gameController) {
NetworkEvent event = actionQueue.take();
event.setIsError(!event.apply(gameController));
serverRMI.notifyAll(event);
serverTCP.notifyAll(event);
if (!playerList.get(gameController.getModel().getCurrentState().getCurrentPlayer().getUserName())) {
actionQueue.offer(new SkipPlayerDisconnected(gameController.getModel().getCurrentState().getCurrentPlayer().getUserName()));
}
return !event.getIsError();
}
}