Class ClientCommand

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

public class ClientCommand extends Object
Represents a command to send JavaScript to one or more clients.
Author:
Dr Michael Gardiner
  • 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

      public ClientCommand(ReusableBufferList buffers)
      Creates a new command with no specified targets.
      Parameters:
      buffers - the raw byte data
    • ClientCommand

      public ClientCommand(byte[] raw, List<String> allowedTargets, List<String> deniedTargets)
      Creates a new command with the given data and targets.
      Parameters:
      raw - the raw data as a byte array
      allowedTargets - the allowed target clients
      deniedTargets - 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 list
      allowedTargets - the allowed target clients
      deniedTargets - the denied target clients
  • Method Details

    • readRaw

      public static ClientCommand readRaw(ReusableBufferList buffers) throws ClientCommandException
      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

      public List<String> getAllowedTargets()
      Retrieves the array of allowed targets for this command.
      Returns:
      an array of target identifiers (client and type)
    • getDeniedTargets

      public List<String> getDeniedTargets()
      Retrieves the array of denied targets for this command.
      Returns:
      an array of target identifiers (client and type)
    • writeJavaScriptTo

      public void writeJavaScriptTo(ReusableBufferList buffers) throws IOException
      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

      public void writeJavaScriptTo(OutputStream out) throws IOException
      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