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 array of allowed targets for this command.Retrieves the array 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 targets are expected to be comma-separated, terminated by a newline.- Parameters:
buffers- the raw byte data- Returns:
- the parsed ClientCommand
- Throws:
ClientCommandException- if the command is malformed or no targets are found
-
getAllowedTargets
Retrieves the array of allowed targets for this command.- Returns:
- an array of target identifiers (client and type)
-
getDeniedTargets
Retrieves the array of denied targets for this command.- Returns:
- an array of target identifiers (client and type)
-
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
-