Package it.polimi.ingsw.view.TUI
Class PlayerTUI
java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
it.polimi.ingsw.view.Player
it.polimi.ingsw.view.TUI.PlayerTUI
- All Implemented Interfaces:
PlayerI
,Serializable
,Remote
class which represent the player on the client side, mutable,
implements Serializable because it will be sent in the socket network
- See Also:
-
Field Summary
Fields inherited from class it.polimi.ingsw.view.Player
activeName, board, chairmanName, closed, CO_1_Done, CO_2_Done, endGame, fullChat, inStream, isChairMan, librariesOfOtherPlayers, library, mySocket, name, netMode, numPlayers, objective, outStream, pingTimeout, pointsMap, pointsUntilNow, showErrors, turnThread, uiMode
Fields inherited from class java.rmi.server.RemoteObject
ref
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add a string (chat message) to the full chat of the gamevoid
Clone the player on the client in the player on the servervoid
function that handle the eventual disconnectionvoid
drawAll()
print the name of the active player, the 2 CO, the PO, the board, the libraries, and then prints spaces before the next execution of drawAll.void
helper function for handling the client (not active) disconnection notification from the servervoid
ping()
method that periodically pings the server from socket clientvoid
method that allow the server ping the RMI clientvoid
pingRMI()
method that periodically pings the server from RMI clientvoid
receivedEventRMI
(Message msg) method (called from remote) that is the equivalent of wait for events of the socket versionboolean
sendChatMsg
(String msg) Send with socket network the message of the chat to the right playersvoid
sendToServer
(Message msg) general method to send a message to the server, it chooses the right network connection of the playerMethods inherited from class it.polimi.ingsw.view.Player
checkRawCoords, doesPlayerExists, getCO_1_Done, getCO_2_Done, getEndGame, getFullChat, getInStream, getIsChairMan, getName, getPrivateObjective, pickCards, setIsChairMan, setName, setPrivateObjective
Methods 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
-
PlayerTUI
constructor that copies a generic Player object inside a new PlayerTUI object- Parameters:
p
- the Player object to copy, received by the server- Throws:
RemoteException
-
PlayerTUI
standard constructor, starts the main game process on the client side- Parameters:
mode
- type of the network chosen by the user- Throws:
RemoteException
-
-
Method Details
-
clone
Clone the player on the client in the player on the server -
addToFullChat
add a string (chat message) to the full chat of the game- Parameters:
s
- the message received, it will be added to the fullChat attribute
-
handleLostClientEvent
helper function for handling the client (not active) disconnection notification from the server- Parameters:
msg
- the message containing the necessary information for reacting to the event
-
sendChatMsg
Send with socket network the message of the chat to the right players- Parameters:
msg
- content of the message
-
drawAll
public void drawAll()print the name of the active player, the 2 CO, the PO, the board, the libraries, and then prints spaces before the next execution of drawAll. It also prints general (useful) information -
connectionLost
function that handle the eventual disconnection- Parameters:
e
- the exception to throw
-
ping
public void ping()method that periodically pings the server from socket client -
pingRMI
public void pingRMI()method that periodically pings the server from RMI client -
receivedEventRMI
method (called from remote) that is the equivalent of wait for events of the socket version- Specified by:
receivedEventRMI
in interfacePlayerI
- Parameters:
msg
- the message received from the server
-
sendToServer
general method to send a message to the server, it chooses the right network connection of the player- Specified by:
sendToServer
in interfacePlayerI
- Parameters:
msg
- the message that must be sent
-
pingClient
public void pingClient()method that allow the server ping the RMI client- Specified by:
pingClient
in interfacePlayerI
-