onMessage method

  1. @override
  2. @mustCallSuper
void onMessage(
  1. WrappedMessage wrapper
)

Handles a non-heartbeat message, usually containing data or commands.

Implementation

@override
@mustCallSuper
void onMessage(WrappedMessage wrapper) {
  if (wrapper.name == AutonomyCommand().messageName) {
    sendWrapper(wrapper);  // acknowledge receipt to the dashboard
    final command = AutonomyCommand.fromBuffer(wrapper.data);
    if (command.abort) {
      collection.orchestrator.abort();
      return;
    }
    if (collection.orchestrator.currentCommand != null) {
      collection.logger.error("Already executing a command", body: "Abort first if you want to switch tasks");
      return;
    }
    collection.orchestrator.onCommand(command);
  }
}