Package net.targetr.rc.client
Class ClientCommand
java.lang.Object
net.targetr.rc.client.ClientCommand
Represents a command to send JavaScript to one or more clients.
- Author:
- Dr Michael Gardiner
-
Constructor Summary
ConstructorsConstructorDescriptionClientCommand(byte[] raw) Creates a new command with no specified targets.ClientCommand(byte[] raw, List<String> allowedTargets, List<String> deniedTargets) Creates a new command with the given data and targets.ClientCommand(ReusableBufferList buffers) Creates a new command with no specified targets.ClientCommand(ReusableBufferList buffers, List<String> allowedTargets, List<String> deniedTargets) Creates a new command with the given data and targets. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the list of allowed targets for this command.Retrieves the list of denied targets for this command.static ClientCommandreadRaw(ReusableBufferList buffers) Reads a list of buffers and parses it into a ClientCommand.voidWrites the JavaScript payload of this command to the specified output stream.voidwriteJavaScriptTo(ReusableBufferList buffers) Writes the JavaScript payload of this command to the specified buffer list.
-
Constructor Details
-
ClientCommand
public ClientCommand(byte[] raw) Creates a new command with no specified targets.- Parameters:
raw- the raw data as a byte array
-
ClientCommand
Creates a new command with no specified targets.- Parameters:
buffers- the raw byte data
-
ClientCommand
Creates a new command with the given data and targets.- Parameters:
raw- the raw data as a byte arrayallowedTargets- the allowed target clientsdeniedTargets- the denied target clients
-
ClientCommand
public ClientCommand(ReusableBufferList buffers, List<String> allowedTargets, List<String> deniedTargets) Creates a new command with the given data and targets.- Parameters:
buffers- the raw data as a buffer listallowedTargets- the allowed target clientsdeniedTargets- the denied target clients
-
-
Method Details
-
readRaw
Reads a list of buffers and parses it into a ClientCommand. The first newline separates target selectors from JavaScript. Selectors are comma-separated;!starts the deny list. An empty target line allows all.- Parameters:
buffers- the raw byte data- Returns:
- the parsed ClientCommand
- Throws:
ClientCommandException- if the newline is missing or the target list cannot be parsed
-
getAllowedTargets
Retrieves the list of allowed targets for this command.- Returns:
- client IDs and app selectors; an empty list allows all
-
getDeniedTargets
Retrieves the list of denied targets for this command.- Returns:
- client IDs and app selectors excluded even when allowed
-
writeJavaScriptTo
Writes the JavaScript payload of this command to the specified buffer list.- Parameters:
buffers- the buffer list to write to- Throws:
IOException- if an I/O error occurs during writing
-
writeJavaScriptTo
Writes the JavaScript payload of this command to the specified output stream.- Parameters:
out- the output stream to write to- Throws:
IOException- if an I/O error occurs during writing
-