sendCommand method

Future<void> sendCommand(
  1. DeviceCommand command, {
  2. bool instant = false,
})

Sends the given command to the back end server. By default the command will be inserted into the queue and sent after all other previously queued commands. Setting the instant flag to true will bypass the queue and send the command immediately. Howver, instant commands will also be lost if the communicator is not currently connected.

Implementation

Future<void> sendCommand(
  DeviceCommand command, {
  bool instant = false,
}) async {
  if (_active == true) {
    if (instant == true && _channel != null) {
      _channel!.sink.add(command.toJson());
    } else {
      _commandQueue.add(command);

      await _sendCommands();
    }
  }
}