java.lang.Object
model.logic.client.Client
-
Field Summary
FieldsModifier and TypeFieldDescriptionjavafx.beans.property.IntegerPropertyjavafx.beans.property.StringPropertystatic boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThe bindButtons function is called by the host to bind the buttons on the client's screen.voidThe closeEverything function is called when the server is closing.javafx.beans.property.StringPropertyThe getMessageFromHost function is a getter function that returns the messageFromHost property.voidThe listenForServerUpdates function is a function that listens for updates from the server.voidThe loadBoard function is used to load the board from a file.voidThe playTurn function is used to send the action that the player wants to take
-
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
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
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.
-