Class Client

java.lang.Object
model.logic.client.Client

public class Client extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    javafx.beans.property.IntegerProperty
     
    javafx.beans.property.StringProperty
     
    static boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Client(String ip, int port, String clientName)
    Client constructor which both initialize the client parameters but also opens a thread for this client to listen on.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    The bindButtons function is called by the host to bind the buttons on the client's screen.
    void
    The closeEverything function is called when the server is closing.
    javafx.beans.property.StringProperty
    The getMessageFromHost function is a getter function that returns the messageFromHost property.
    void
    The listenForServerUpdates function is a function that listens for updates from the server.
    void
    The loadBoard function is used to load the board from a file.
    void
    playTurn(String action)
    The playTurn function is used to send the action that the player wants to take

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • playerId

      public javafx.beans.property.IntegerProperty playerId
    • playTurn

      public javafx.beans.property.StringProperty playTurn
    • serverIsRunning

      public static volatile boolean serverIsRunning
  • Constructor Details

    • Client

      public Client(String ip, int port, String clientName)
      Client constructor which both initialize the client parameters but also opens a thread for this client to listen on.
      Parameters:
      ip - - Ip of the Host server.
      port - - Port 0f the Host server.
      clientName - - Client name for the game.
  • Method Details

    • listenForServerUpdates

      public void listenForServerUpdates()
      The listenForServerUpdates function is a function that listens for updates from the server. It does this by creating a new thread, and then running an infinite loop in which it checks if there are any messages from the server. If there are, it will check what message was sent and act accordingly.
    • playTurn

      public void playTurn(String action)
      The playTurn function is used to send the action that the player wants to take
      Parameters:
      action - action Send the action to the server
    • getMessageFromHost

      public javafx.beans.property.StringProperty getMessageFromHost()
      The getMessageFromHost function is a getter function that returns the messageFromHost property.
      Returns:
      A string property
    • loadBoard

      public void loadBoard()
      The loadBoard function is used to load the board from a file. It sets the messageFromHost value to "loadBoard" so that it can be read by the host and then executed.
    • bindButtons

      public void bindButtons()
      The bindButtons function is called by the host to bind the buttons on the client's screen. The function takes no parameters and returns nothing.
    • closeEverything

      public void closeEverything()
      The closeEverything function is called when the server is closing. It sends a message to all clients that the server is closing, and then closes the server socket.