Package client
Class SingleClient
java.lang.Object
client.SingleClient
The SingleClient acts as a singleton that interacts with a single instance of a Client object.
This is useful for the behaviors as it means clients do not to be closed and opened for each behavior.
- Since:
- 2023
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns whether or not the client is currently connected.static SingleClientReturns the instance of this client and initialises it if it is null.static PacketReturns the latest packet from the server.static PacketGets a packet from the server.static voidstatic voidsendDataPacket(String data) Sends a piece of data that is passed as a string.A packet is constructed from the string and then sent via the client.static voidsendPacket(Packet packet) Sends a packet via the clients sendPacket() method.static voidsendStatePacket(States state) Sends a state via a packet which is constructed and sent via the client.static voidsetLatestPacket(Packet packet) Sets the value of the latest packet from the server.
-
Method Details
-
initialize
public static void initialize() -
getInstance
Returns the instance of this client and initialises it if it is null.- Returns:
- SingleClient
-
clientConnected
public static boolean clientConnected()Returns whether or not the client is currently connected.- Returns:
- boolean
-
sendPacket
Sends a packet via the clients sendPacket() method.- Parameters:
packet-
-
sendDataPacket
Sends a piece of data that is passed as a string.A packet is constructed from the string and then sent via the client.- Parameters:
data-
-
sendStatePacket
Sends a state via a packet which is constructed and sent via the client.- Parameters:
state- current state of robot
-
getLatestPacket
Returns the latest packet from the server.- Returns:
- Packet
-
setLatestPacket
Sets the value of the latest packet from the server.- Parameters:
packet-
-
getPacket
Gets a packet from the server.- Returns:
- Packet
-