Class RMIServer

java.lang.Object
it.polimi.ingsw.Server.RMIServer

public class RMIServer extends Object
RMI Server, uses Status callbacks to inform clients of game's evolution
Author:
Gruppo AM34
  • Field Details

  • Constructor Details

    • RMIServer

      public RMIServer(Map<String,GameController> identifierToController, Map<GameController,Semaphore> controllerToSemaphore, Map<GameController,Object> controllerToCommuter, Map<GameController,Object> controllerToLobbyCommuter)
      RMIServer constructor, managed by the Server Manager by default
      Parameters:
      identifierToController - maps game's identifiers to GameControllers
      controllerToSemaphore - maps GameControllers to synchronization semaphores
      controllerToCommuter - maps GamesController to synchronization commuters
      controllerToLobbyCommuter - maps GameController to synchronization lobbyCommuters
  • Method Details

    • main

      public static void main(String[] args)
      Main method, welcoming Server management console
      Parameters:
      args - default arguments array
    • sendScoreBoard

      private static void sendScoreBoard(ClientStatusInterface csi, GameController controller) throws RemoteException
      Sets Final Scoreboard and informs client of the availability
      Parameters:
      csi - Client Status Interface, remote interface of client's implementation of the Status Object
      controller - Game's Controller
      Throws:
      RemoteException - Related to RMI
    • endGameHandler

      public static void endGameHandler(GameController gc, boolean invokedBySocket)
      Implements End Game strategy, informing all clients (RMI and Socket ones) to disconnect ad deallocates Model Objects from global structures
      Parameters:
      gc - Game's Controller
      invokedBySocket - to avoid Server callbacks
    • manage

      public void manage() throws Exception
      abstraction method, invoked by Status Intermediate by default and listening for client status updates
      Throws:
      Exception - related to Model management
    • loginCheck

      private GameController loginCheck(ClientStatusInterface csi, String clientIdentifier, String clientNickname) throws RemoteException
      Game's lobby admission and re-enter strategy
      Parameters:
      csi - Client Status Interface, remote interface of client's implementation of the Status Object
      clientIdentifier - Game's identifier, as given by the client (checked before)
      clientNickname - Game's nickname, as given by the client (checked before)
      Returns:
      Game Controller, obtained after the login phase
      Throws:
      RemoteException - related to RMI
    • admission

      private RMIServer.AdmissionResult admission(ClientStatusInterface csi, String clientNickname, GameController controller) throws InterruptedException, RemoteException
      Admission phase implementation
      Parameters:
      csi - Client Status Interface, remote interface of client's implementation of the Status Object
      clientNickname - Game's nickname, as given by the client (checked before)
      controller - Game's Controller
      Returns:
      an Admission Result
      Throws:
      InterruptedException - related to synchronization management
      RemoteException - related to RMI
    • turnManagement

      private void turnManagement(ClientStatusInterface csi, String clientIdentifier, String clientNickname, GameController controller, RMIServer.AdmissionResult admissionResult) throws Exception
      Turn Management implementation
      Parameters:
      csi - Client Status Interface, remote interface of client's implementation of the Status Object
      clientIdentifier - Game's identifier, as given by the client (checked before)
      clientNickname - Game's nickname, as given by the client (checked before)
      controller - Game's Controller
      admissionResult - Admission Result
      Throws:
      Exception - related to Model management