Package client

Class SingleClient

java.lang.Object
client.SingleClient

public final class SingleClient extends Object
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 Details

    • initialize

      public static void initialize()
    • getInstance

      public static SingleClient 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

      public static void sendPacket(Packet packet)
      Sends a packet via the clients sendPacket() method.
      Parameters:
      packet -
    • sendDataPacket

      public static void sendDataPacket(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.
      Parameters:
      data -
    • sendStatePacket

      public static void sendStatePacket(States state)
      Sends a state via a packet which is constructed and sent via the client.
      Parameters:
      state - current state of robot
    • getLatestPacket

      public static Packet getLatestPacket()
      Returns the latest packet from the server.
      Returns:
      Packet
    • setLatestPacket

      public static void setLatestPacket(Packet packet)
      Sets the value of the latest packet from the server.
      Parameters:
      packet -
    • getPacket

      public static Packet getPacket()
      Gets a packet from the server.
      Returns:
      Packet