Class PlayerTUI

All Implemented Interfaces:
PlayerI, Serializable, Remote

public class PlayerTUI extends Player implements Serializable, PlayerI
class which represent the player on the client side, mutable, implements Serializable because it will be sent in the socket network
See Also:
  • Constructor Details

    • PlayerTUI

      public PlayerTUI(Player p) throws RemoteException
      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

      public PlayerTUI(NetMode mode, String opt) throws RemoteException
      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

      public void clone(PlayerTUI p)
      Clone the player on the client in the player on the server
      Overrides:
      clone in class Player
      Parameters:
      p - the Player that will be cloned in the current Object
    • addToFullChat

      public void addToFullChat(String s)
      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

      public void handleLostClientEvent(Message msg)
      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

      public boolean sendChatMsg(String msg)
      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

      public void connectionLost(Exception e)
      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

      public void receivedEventRMI(Message msg)
      method (called from remote) that is the equivalent of wait for events of the socket version
      Specified by:
      receivedEventRMI in interface PlayerI
      Parameters:
      msg - the message received from the server
    • sendToServer

      public void sendToServer(Message msg)
      general method to send a message to the server, it chooses the right network connection of the player
      Specified by:
      sendToServer in interface PlayerI
      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 interface PlayerI