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 TypeMethodDescriptionvoidconnect(UUID connectionID, RemoteGameEventListener listener) Connects the player to the servervoidcreateGame(UUID connectionID, String gameId, Integer players) Creates a gamevoiddeleteGame(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 playervoidSends a heartbeat to the servervoidjoinGame(UUID connectionID, String gameID, CardSideType sideType) Joins a game, by selecting the side of the starter cardvoidJoins a lobbyvoidleaveLobby(UUID connectionID) Leaves a lobbyvoidlobbyChooseObjective(UUID connectionID, Boolean first) Chooses the objective card of the playervoidlobbySetNickname(UUID connectionID, String nickname) Sets the nickname of the playervoidlobbySetTokenColor(UUID connectionID, TokenColor color) Sets the token color of the playervoidStarts the next turn, to be used when a player is skipping their turn (for example, when the player is disconnected)voidnextTurn(UUID connectionID, DrawingCardSource drawingSource, DrawingDeckType deckType) Starts the next turn by drawing cards from the deckvoidplaceCard(UUID connectionID, Integer playerHandCardNumber, CardSideType side, Position position) Places a card on the game boardvoidsendChatMessage(UUID connectionID, ChatMessage message) Gets the available tokens of the playerMethods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, exportObject, exportObject, unexportObjectMethods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
-
Constructor Details
-
RMIServerConnectionHandlerImpl
- Throws:
RemoteException
-
-
Method Details
-
getGames
Description copied from interface:RMIServerConnectionHandlerGets the list of available game IDs- Specified by:
getGamesin interfaceRMIServerConnectionHandler- Throws:
RemoteException
-
getGamesCurrentPlayers
Description copied from interface:RMIServerConnectionHandlerGets the current number of players in each game- Specified by:
getGamesCurrentPlayersin interfaceRMIServerConnectionHandler- Throws:
RemoteException
-
getGamesMaxPlayers
Description copied from interface:RMIServerConnectionHandlerGets the maximum number of players in each game- Specified by:
getGamesMaxPlayersin interfaceRMIServerConnectionHandler- Throws:
RemoteException
-
getLobbyObjectiveCards
public javafx.util.Pair<Integer,Integer> getLobbyObjectiveCards(UUID connectionID) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerGets the ids of the objective cards that the lobby has to offer to the player- Specified by:
getLobbyObjectiveCardsin interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the player- Throws:
RemoteExceptionInvalidActionException
-
getLobbyStarterCard
public Integer getLobbyStarterCard(UUID connectionID) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerGets the id of the starter card that the lobby has to offer to the player- Specified by:
getLobbyStarterCardin interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the player- Throws:
RemoteExceptionInvalidActionException
-
joinLobby
public void joinLobby(UUID connectionID, String gameID) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerJoins a lobby- Specified by:
joinLobbyin interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the playergameID- The game ID of the lobby- Throws:
RemoteExceptionInvalidActionException
-
lobbySetTokenColor
public void lobbySetTokenColor(UUID connectionID, TokenColor color) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerSets the token color of the player- Specified by:
lobbySetTokenColorin interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the playercolor- The token color of the player- Throws:
RemoteExceptionInvalidActionException
-
lobbySetNickname
public void lobbySetNickname(UUID connectionID, String nickname) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerSets the nickname of the player- Specified by:
lobbySetNicknamein interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the playernickname- The nickname of the player- Throws:
RemoteExceptionInvalidActionException
-
lobbyChooseObjective
public void lobbyChooseObjective(UUID connectionID, Boolean first) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerChooses the objective card of the player- Specified by:
lobbyChooseObjectivein interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the playerfirst- True if the player chooses the first objective card, false otherwise- Throws:
RemoteExceptionInvalidActionException
-
joinGame
public void joinGame(UUID connectionID, String gameID, CardSideType sideType) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerJoins a game, by selecting the side of the starter card- Specified by:
joinGamein interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the player- Throws:
RemoteExceptionInvalidActionException
-
createGame
public void createGame(UUID connectionID, String gameId, Integer players) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerCreates a game- Specified by:
createGamein interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the playergameId- The game ID of the gameplayers- The number of players of the game- Throws:
RemoteExceptionInvalidActionException
-
deleteGame
public void deleteGame(UUID connectionID, String gameId) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerDeletes a game- Specified by:
deleteGamein interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the playergameId- The game ID of the game- Throws:
RemoteExceptionInvalidActionException
-
nextTurn
Description copied from interface:RMIServerConnectionHandlerStarts the next turn, to be used when a player is skipping their turn (for example, when the player is disconnected)- Specified by:
nextTurnin interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the player- Throws:
RemoteExceptionInvalidActionException
-
nextTurn
public void nextTurn(UUID connectionID, DrawingCardSource drawingSource, DrawingDeckType deckType) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerStarts the next turn by drawing cards from the deck- Specified by:
nextTurnin interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the playerdrawingSource- The source of the drawing cardsdeckType- The type of the drawing deck- Throws:
RemoteExceptionInvalidActionException
-
placeCard
public void placeCard(UUID connectionID, Integer playerHandCardNumber, CardSideType side, Position position) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerPlaces a card on the game board- Specified by:
placeCardin 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:
RemoteExceptionInvalidActionException
-
leaveLobby
Description copied from interface:RMIServerConnectionHandlerLeaves a lobby- Specified by:
leaveLobbyin interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the player- Throws:
RemoteExceptionInvalidActionException
-
sendChatMessage
public void sendChatMessage(UUID connectionID, ChatMessage message) throws RemoteException, InvalidActionException Description copied from interface:RMIServerConnectionHandlerGets the available tokens of the player- Specified by:
sendChatMessagein interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the playermessage- The message to be sent to the player- Throws:
RemoteExceptionInvalidActionException
-
connect
Description copied from interface:RMIServerConnectionHandlerConnects the player to the server- Specified by:
connectin interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the playerlistener- The listener of the player- Throws:
RemoteException
-
heartBeat
Description copied from interface:RMIServerConnectionHandlerSends a heartbeat to the server- Specified by:
heartBeatin interfaceRMIServerConnectionHandler- Parameters:
connectionID- The connection ID of the player- Throws:
RemoteExceptionPlayerNotFoundException
-