onDisconnect method

  1. @override
Future<void> onDisconnect()
inherited

Sends a Disconnect message to the dashboard and sets destination to null.

Override this function to run custom code when the device on the other end disconnects. For example, put code to stop the rover from driving in here when connection is lost.

Implementation

@override
Future<void> onDisconnect() async {
  logger.info("Port $port is disconnected from $destination");
  sendMessage(Disconnect(sender: device));
  destination = null;
  await collection?.onDisconnect();
  await super.onDisconnect();
}