sendCmd method

Future<OnyxMessage?> sendCmd(
  1. String cmd, [
  2. bool andBoost = false
])

andBoost will flag the heartbeat to poll Onyx more frequently

Implementation

Future<OnyxMessage?> sendCmd(String cmd, [bool andBoost = false]) async {
  // never send an empty command
  // all other commands will receive a response
  if (cmd.trim().isEmpty) return null;

  // wait until the previous command is completed if there is one
  await _completer?.future;

  if (!connected) await connect();
  _dbg('${DateTime.now().toIso8601String()} ONYX SEND: $cmd');

  _socket?.write(cmd + '\r\n');

  if (andBoost) boostHeartbeat(6);
  return _expectResponse(timeoutMsg: 'Sending "$cmd", command timed out...');
}