acceptStream method

  1. @override
Future<YamuxStream> acceptStream()
override

Accepts an inbound stream

Implementation

@override
Future<YamuxStream> acceptStream() async {
  if (_closed && _incomingStreamsController.isClosed) {
      throw StateError('Session is closed, cannot accept new streams.');
  }
  final p2pStream = await incomingStreams.first;
  if (p2pStream is YamuxStream) {
    return p2pStream;
  } else {
    throw StateError('Incoming stream is not a YamuxStream, which is unexpected.');
  }
}