Module polimi.ingsw.am21.codex
Class RMIServerConnectionHandlerImpl
java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
polimi.ingsw.am21.codex.connection.server.RMI.RMIServerConnectionHandlerImpl
- All Implemented Interfaces:
Serializable
,Remote
,RMIServerConnectionHandler
public class RMIServerConnectionHandlerImpl
extends UnicastRemoteObject
implements RMIServerConnectionHandler
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
connect
(UUID connectionID, RemoteGameEventListener listener) Connects the player to the servervoid
createGame
(UUID connectionID, String gameId, Integer players) Creates a gamevoid
deleteGame
(UUID connectionID, String gameId) Deletes a gamegetGames()
Gets the list of available game IDsGets the current number of players in each gameGets the maximum number of players in each gamegetLobbyObjectiveCards
(UUID connectionID) Gets the ids of the objective cards that the lobby has to offer to the playergetLobbyStarterCard
(UUID connectionID) Gets the id of the starter card that the lobby has to offer to the playervoid
Sends a heartbeat to the servervoid
joinGame
(UUID connectionID, String gameID, CardSideType sideType) Joins a game, by selecting the side of the starter cardvoid
Joins a lobbyvoid
leaveLobby
(UUID connectionID) Leaves a lobbyvoid
lobbyChooseObjective
(UUID connectionID, Boolean first) Chooses the objective card of the playervoid
lobbySetNickname
(UUID connectionID, String nickname) Sets the nickname of the playervoid
lobbySetTokenColor
(UUID connectionID, TokenColor color) Sets the token color of the playervoid
Starts the next turn, to be used when a player is skipping their turn (for example, when the player is disconnected)void
nextTurn
(UUID connectionID, DrawingCardSource drawingSource, DrawingDeckType deckType) Starts the next turn by drawing cards from the deckvoid
placeCard
(UUID connectionID, Integer playerHandCardNumber, CardSideType side, Position position) Places a card on the game boardvoid
sendChatMessage
(UUID connectionID, ChatMessage message) Gets the available tokens of the playerMethods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, exportObject, exportObject, unexportObject
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
-
Constructor Details
-
RMIServerConnectionHandlerImpl
- Throws:
RemoteException
-
-
Method Details
-
getGames
Description copied from interface:RMIServerConnectionHandler
Gets the list of available game IDs- Specified by:
getGames
in interfaceRMIServerConnectionHandler
- Throws:
RemoteException
-
getGamesCurrentPlayers
Description copied from interface:RMIServerConnectionHandler
Gets the current number of players in each game- Specified by:
getGamesCurrentPlayers
in interfaceRMIServerConnectionHandler
- Throws:
RemoteException
-
getGamesMaxPlayers
Description copied from interface:RMIServerConnectionHandler
Gets the maximum number of players in each game- Specified by:
getGamesMaxPlayers
in interfaceRMIServerConnectionHandler
- Throws:
RemoteException
-
getLobbyObjectiveCards
public javafx.util.Pair<Integer,Integer> getLobbyObjectiveCards(UUID connectionID) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Gets the ids of the objective cards that the lobby has to offer to the player- Specified by:
getLobbyObjectiveCards
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the player- Throws:
RemoteException
InvalidActionException
-
getLobbyStarterCard
public Integer getLobbyStarterCard(UUID connectionID) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Gets the id of the starter card that the lobby has to offer to the player- Specified by:
getLobbyStarterCard
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the player- Throws:
RemoteException
InvalidActionException
-
joinLobby
public void joinLobby(UUID connectionID, String gameID) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Joins a lobby- Specified by:
joinLobby
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the playergameID
- The game ID of the lobby- Throws:
RemoteException
InvalidActionException
-
lobbySetTokenColor
public void lobbySetTokenColor(UUID connectionID, TokenColor color) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Sets the token color of the player- Specified by:
lobbySetTokenColor
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the playercolor
- The token color of the player- Throws:
RemoteException
InvalidActionException
-
lobbySetNickname
public void lobbySetNickname(UUID connectionID, String nickname) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Sets the nickname of the player- Specified by:
lobbySetNickname
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the playernickname
- The nickname of the player- Throws:
RemoteException
InvalidActionException
-
lobbyChooseObjective
public void lobbyChooseObjective(UUID connectionID, Boolean first) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Chooses the objective card of the player- Specified by:
lobbyChooseObjective
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the playerfirst
- True if the player chooses the first objective card, false otherwise- Throws:
RemoteException
InvalidActionException
-
joinGame
public void joinGame(UUID connectionID, String gameID, CardSideType sideType) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Joins a game, by selecting the side of the starter card- Specified by:
joinGame
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the player- Throws:
RemoteException
InvalidActionException
-
createGame
public void createGame(UUID connectionID, String gameId, Integer players) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Creates a game- Specified by:
createGame
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the playergameId
- The game ID of the gameplayers
- The number of players of the game- Throws:
RemoteException
InvalidActionException
-
deleteGame
public void deleteGame(UUID connectionID, String gameId) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Deletes a game- Specified by:
deleteGame
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the playergameId
- The game ID of the game- Throws:
RemoteException
InvalidActionException
-
nextTurn
Description copied from interface:RMIServerConnectionHandler
Starts the next turn, to be used when a player is skipping their turn (for example, when the player is disconnected)- Specified by:
nextTurn
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the player- Throws:
RemoteException
InvalidActionException
-
nextTurn
public void nextTurn(UUID connectionID, DrawingCardSource drawingSource, DrawingDeckType deckType) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Starts the next turn by drawing cards from the deck- Specified by:
nextTurn
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the playerdrawingSource
- The source of the drawing cardsdeckType
- The type of the drawing deck- Throws:
RemoteException
InvalidActionException
-
placeCard
public void placeCard(UUID connectionID, Integer playerHandCardNumber, CardSideType side, Position position) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Places a card on the game board- Specified by:
placeCard
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the playerplayerHandCardNumber
- The index of the card in the player's handside
- The side of the cardposition
- The position of the card- Throws:
RemoteException
InvalidActionException
-
leaveLobby
Description copied from interface:RMIServerConnectionHandler
Leaves a lobby- Specified by:
leaveLobby
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the player- Throws:
RemoteException
InvalidActionException
-
sendChatMessage
public void sendChatMessage(UUID connectionID, ChatMessage message) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandler
Gets the available tokens of the player- Specified by:
sendChatMessage
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the playermessage
- The message to be sent to the player- Throws:
RemoteException
InvalidActionException
-
connect
Description copied from interface:RMIServerConnectionHandler
Connects the player to the server- Specified by:
connect
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the playerlistener
- The listener of the player- Throws:
RemoteException
-
heartBeat
Description copied from interface:RMIServerConnectionHandler
Sends a heartbeat to the server- Specified by:
heartBeat
in interfaceRMIServerConnectionHandler
- Parameters:
connectionID
- The connection ID of the player- Throws:
RemoteException
PlayerNotFoundException
-