close method

Future<void> close()

Close the connection to the Robot. This should be done to release resources on the robot.

await machine.close();

Implementation

Future<void> close() async {
  _logger.d('Closing RobotClient connection');
  try {
    _checkConnectionTask?.cancel();
    _shouldAttemptReconnection = false;
    try {
      await _streamManager.closeAll();
    } catch (_) {
      // Do nothing -- we don't care if this fails,
      // the server should clean up disconnected streams automatically.
    }
    _sessionsClient.stop();
    await _channel.shutdown();
  } catch (e) {
    _logger.w('Did not cleanly close RobotClient connection', error: e);
  }
}