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 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

      public List<String> getAllowedTargets()
      Retrieves the list of allowed targets for this command.
      Returns:
      client IDs and app selectors; an empty list allows all
    • getDeniedTargets

      public List<String> getDeniedTargets()
      Retrieves the list of denied targets for this command.
      Returns:
      client IDs and app selectors excluded even when allowed
    • 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