Package net.targetr.rc.client
Class Client
java.lang.Object
net.targetr.rc.client.Client
Represents a WebBrowser in a room. Facilitates communications.
- Author:
- Dr Michael Gardiner
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceHandler invoked for direct, real-time command dispatch omitting the queue. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe current client request associated with this client. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetState()Retrieves the current state of the client request as a map.booleanChecks if the client has commands pending in the queue.booleanisActive(long recent) Checks if the client is currently active or has recently ended.booleanmatchesClientOrType(String value) Checks if the value matches the client or app.Retrieves and removes the next command from the queue.voidsendCommand(ClientCommand cmd) Enqueues a command to be sent to the client and notifies any waiting threads.voidSets a handler to attempt instantaneous delivery of a command.
-
Field Details
-
clientRequest
The current client request associated with this client.
-
-
Constructor Details
-
Client
public Client()Constructs a new Client instance.
-
-
Method Details
-
setDirectSendHandler
Sets a handler to attempt instantaneous delivery of a command.- Parameters:
handler- the functional handler
-
sendCommand
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
Retrieves and removes the next command from the queue.- Returns:
- the next command, or
nullif the queue is empty
-
getState
Retrieves the current state of the client request as a map.- Returns:
- a map containing the state details, or
nullif 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:
trueif the request is still active or ended after the given timestamp,falseotherwise
-
matchesClientOrType
Checks if the value matches the client or app.- Parameters:
value- the value string to check- Returns:
trueif the value matches client or app,falseotherwise
-