create method

  1. @override
Future<void> create()
override

Creates.

Implementation

@override
Future<void> create() async {
  if (_created) return;
  if (_disposed) throw StateError('Cannot create a disposed stream');
  _created = true;

  // Claim a routing identity up front. A stream that only consumes never
  // calls createOutlet, and without this the hub would have no way to
  // deliver to it.
  _slot = await connection.announce(descriptor, publish: false);
  _inboundSubscription = connection.inbound.listen(_onInbound);
  _outgoingSubscription = _outgoing.stream.listen((message) {
    unawaited(Future.sync(() => sendMessage(message)));
  });
}