close method

Future<void> close()

Close the client

Implementation

Future<void> close() async {
  _logger.info('Closing client');

  // Cancel all subscriptions
  for (final subscription in _subscriptions.values) {
    subscription.cancel();
  }
  _subscriptions.clear();

  // Close dispatcher
  await _dispatcher.close();

  // Close streams
  await _messageController.close();
  await _stateController.close();
  await _errorController.close();

  _logger.info('Client closed');
}