java.lang.Object
it.polimi.ingsw.am13.client.network.rmi.NetworkHandlerRMI
- All Implemented Interfaces:
NetworkHandler
RMI implementation of
NetworkHandler
, which is used by the client to send messages to the server-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate GameControllerRMIIF
The controller of the match associated to this network handlerprivate final LobbyRMIIF
The controller that manages all the gamesprivate Thread
Thread sending periodically pings to serverprivate PlayerLobby
The player associated to this network handlerprivate final View
The user interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Choose the personal objective cardvoid
createRoom
(String nickname, Token token, int nPlayers) Create a room with the passed parametersvoid
getRooms()
Get the existing roomsgetView()
void
Make the player join the specified roomvoid
Make the player leave the room he is currently part ofvoid
pickCard
(CardPlayableIF card) Pick the passed cardprivate void
ping()
Ping the servervoid
playCard
(CardPlayableIF card, Coordinates coords, Side side) Play a card according to the parametersvoid
playStarter
(Side side) Play the starter cardvoid
Reconnect the passed player to an existing game he was previously part ofvoid
sendChatMessage
(List<PlayerLobby> receivers, String text) Send a chat message to the receivers (either a single player, or all the players)void
setController
(GameControllerRMIIF controller) Sets the controller to the passed parametervoid
Starts the thread sending pings to servervoid
stopPing()
Stops the thread sending pings to server
-
Field Details
-
lobby
The controller that manages all the games -
player
The player associated to this network handler -
controller
The controller of the match associated to this network handler -
view
The user interface -
pingThread
Thread sending periodically pings to server
-
-
Constructor Details
-
NetworkHandlerRMI
Initializes lobby and view- Parameters:
lobby
- the controller that manages all the gamesview
- the user interface
-
-
Method Details
-
getPlayer
- Specified by:
getPlayer
in interfaceNetworkHandler
- Returns:
- the current valid player associated to this NetworkHandler. Null is no valid player is currently associated.
-
getView
- Returns:
- the user interface
-
setController
Sets the controller to the passed parameter- Parameters:
controller
- the controller of the match associated to this network handler
-
getRooms
public void getRooms()Get the existing rooms- Specified by:
getRooms
in interfaceNetworkHandler
-
createRoom
Create a room with the passed parameters- Specified by:
createRoom
in interfaceNetworkHandler
- Parameters:
nickname
- of the player who is creating the roomtoken
- of the player who is creating the roomnPlayers
- of the room that is being created
-
joinRoom
Make the player join the specified room- Specified by:
joinRoom
in interfaceNetworkHandler
- Parameters:
nickname
- the nickname the client wants to join the room withtoken
- chosen by the player who wants to join the roomgameId
- of the game that the client wants to join
-
reconnect
Reconnect the passed player to an existing game he was previously part of- Specified by:
reconnect
in interfaceNetworkHandler
- Parameters:
nickname
- of the player who wants to reconnecttoken
- of the player who wants to reconnect
-
leaveRoom
public void leaveRoom()Make the player leave the room he is currently part of- Specified by:
leaveRoom
in interfaceNetworkHandler
-
playStarter
Play the starter card- Specified by:
playStarter
in interfaceNetworkHandler
- Parameters:
side
- on which the starter card should be played
-
choosePersonalObjective
Choose the personal objective card- Specified by:
choosePersonalObjective
in interfaceNetworkHandler
- Parameters:
card
- the chosen personal objective
-
playCard
Play a card according to the parameters- Specified by:
playCard
in interfaceNetworkHandler
- Parameters:
card
- the player wants to playcoords
- where the card should be playedside
- on which the card should be played
-
pickCard
Pick the passed card- Specified by:
pickCard
in interfaceNetworkHandler
- Parameters:
card
- the player wants to pick
-
ping
private void ping()Ping the server -
startPing
public void startPing()Starts the thread sending pings to server- Specified by:
startPing
in interfaceNetworkHandler
-
stopPing
public void stopPing()Stops the thread sending pings to server- Specified by:
stopPing
in interfaceNetworkHandler
-
sendChatMessage
Send a chat message to the receivers (either a single player, or all the players)- Specified by:
sendChatMessage
in interfaceNetworkHandler
- Parameters:
receivers
- of the chat messagetext
- of the chat message
-