Package it.polimi.ingsw.Server
Class RMIServer
java.lang.Object
it.polimi.ingsw.Server.RMIServer
RMI Server, uses Status callbacks to inform clients of game's evolution
- Author:
- Gruppo AM34
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static final record
Admission phase result -
Field Summary
Modifier and TypeFieldDescriptionprivate static Map<ClientStatusInterface,
GameController> private static Map<GameController,
Object> private static Map<GameController,
Object> private static Map<GameController,
Semaphore> private static final int
private static final ExecutorService
private final com.google.gson.Gson
private static Map<String,
GameController> private StatusIntermediate
private static int
private final com.google.gson.ExclusionStrategy
private RMIController
-
Constructor Summary
ConstructorDescriptionRMIServer
(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 -
Method Summary
Modifier and TypeMethodDescriptionprivate RMIServer.AdmissionResult
admission
(ClientStatusInterface csi, String clientNickname, GameController controller) Admission phase implementationstatic 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 structuresprivate GameController
loginCheck
(ClientStatusInterface csi, String clientIdentifier, String clientNickname) Game's lobby admission and re-enter strategystatic void
Main method, welcoming Server management consolevoid
manage()
abstraction method, invoked by Status Intermediate by default and listening for client status updatesprivate static void
sendScoreBoard
(ClientStatusInterface csi, GameController controller) Sets Final Scoreboard and informs client of the availabilityprivate void
turnManagement
(ClientStatusInterface csi, String clientIdentifier, String clientNickname, GameController controller, RMIServer.AdmissionResult admissionResult) Turn Management implementation
-
Field Details
-
countParameters
private static final int countParameters- See Also:
-
executors
-
PORT
private static int PORT -
identifierToController
-
controllerToSemaphore
-
controllerToCommuter
-
controllerToLobbyCommuter
-
clientStatusToController
-
serializationStrategy
private final com.google.gson.ExclusionStrategy serializationStrategy -
gson
private final com.google.gson.Gson gson -
intermediate
-
serverController
-
-
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 GameControllerscontrollerToSemaphore
- maps GameControllers to synchronization semaphorescontrollerToCommuter
- maps GamesController to synchronization commuterscontrollerToLobbyCommuter
- maps GameController to synchronization lobbyCommuters
-
-
Method Details
-
main
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 Objectcontroller
- Game's Controller- Throws:
RemoteException
- Related to RMI
-
endGameHandler
Implements End Game strategy, informing all clients (RMI and Socket ones) to disconnect ad deallocates Model Objects from global structures- Parameters:
gc
- Game's ControllerinvokedBySocket
- to avoid Server callbacks
-
manage
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 ObjectclientIdentifier
- 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 ObjectclientNickname
- Game's nickname, as given by the client (checked before)controller
- Game's Controller- Returns:
- an Admission Result
- Throws:
InterruptedException
- related to synchronization managementRemoteException
- 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 ObjectclientIdentifier
- Game's identifier, as given by the client (checked before)clientNickname
- Game's nickname, as given by the client (checked before)controller
- Game's ControlleradmissionResult
- Admission Result- Throws:
Exception
- related to Model management
-