close method

Future<void> close([
  1. int? code,
  2. String? reason
])

Close the connection to the ROS node, an exit code and reason can be optionally specified.

Implementation

Future<void> close([int? code, String? reason]) async {
  /// Close listener and websocket.
  await _channelListener.cancel();
  await _channel.sink.close(code, reason);

  /// Update the connection status.
  _statusController.add(Status.closed);
  status = Status.closed;
}