Class Client

java.lang.Object
net.targetr.rc.client.Client

public class Client extends Object
Represents a WebBrowser in a room. Facilitates communications.
Author:
Dr Michael Gardiner
  • Field Details

    • clientRequest

      public volatile ClientRequest clientRequest
      The current client request associated with this client.
  • Constructor Details

    • Client

      public Client()
      Constructs a new Client instance.
  • Method Details

    • setDirectSendHandler

      public void setDirectSendHandler(Client.DirectSendHandler handler)
      Sets a handler to attempt instantaneous delivery of a command.
      Parameters:
      handler - the functional handler
    • sendCommand

      public void sendCommand(ClientCommand cmd)
      Enqueues a command to be sent to the client and notifies any waiting threads.
      Parameters:
      cmd - the command to send
    • hasCommands

      public boolean hasCommands()
      Checks if the client has commands pending in the queue.
      Returns:
      true if commands are backlogged
    • popCommand

      public ClientCommand popCommand()
      Retrieves and removes the next command from the queue.
      Returns:
      the next command, or null if the queue is empty
    • getState

      public Map<String,Object> getState()
      Retrieves the current state of the client request as a map.
      Returns:
      a map containing the state details, or null if there is no client request
    • isActive

      public boolean isActive(long recent)
      Checks if the client is currently active or has recently ended.
      Parameters:
      recent - the timestamp to check against if the request recently ended
      Returns:
      true if the request is still active or ended after the given timestamp, false otherwise
    • matchesClientOrType

      public boolean matchesClientOrType(String value)
      Checks if the value matches the client or app.
      Parameters:
      value - the value string to check
      Returns:
      true if the value matches client or app, false otherwise