onCommandReceived property

Future<void> Function(DeviceCommand) onCommandReceived

Implementation

Future<void> Function(DeviceCommand) get onCommandReceived =>
    (command) async {
      _lastPing = DateTime.now();
      _resetTimeout();

      if (_onCommandReceived != null) {
        if (command is CommandAck || command is PingCommand) {
          logger.finest('[RECEIVED COMMAND]: received: [${command.type}]');
        } else {
          logger.info('[RECEIVED COMMAND]: received: [${command.type}]');
        }

        await _onCommandReceived!(command);
      }
    };
void onCommandReceived=(Future<void> handler(DeviceCommand))

Implementation

set onCommandReceived(Future<void> Function(DeviceCommand) handler) {
  if (handler == onCommandReceived) {
    throw Exception(
      '[LOOP]: Attempted to register the same handler as [onCommandReceived]; aborting',
    );
  }
  _onCommandReceived = handler;
}