pair static method

Creates two connected ends: bytes added to one arrive on the other's input.

Implementation

static (InMemoryConnection, InMemoryConnection) pair() {
  // Both controllers are closed by the shared _PairCloser.
  // ignore: close_sinks
  final toServer = StreamController<Uint8List>();
  // ignore: close_sinks
  final toClient = StreamController<Uint8List>();
  final closer = _PairCloser(toServer, toClient);
  return (
    InMemoryConnection._(toClient, toServer, closer),
    InMemoryConnection._(toServer, toClient, closer),
  );
}