close method

void close()

Leave the bus and close the ports. In the main isolate it also closes the hub.

Internal: Dox calls it when the app stops. Apps do not call it.

Implementation

void close() {
  if (_inbox != null) _send(<Object>['leave', _id]);
  _inbox?.close();
  _inbox = null;
  _hubPort?.close();
  _hubPort = null;
  _members.clear();
  _hub = null;
  _id = 1;
  _size = 1;
  for (StreamController<Object?> channel in _channels.values) {
    unawaited(channel.close());
  }
  _channels.clear();
}