pair static method

(RpcFrameMultiplexedChannel, RpcFrameMultiplexedChannel) pair({
  1. RpcSecurityPolicy policy = const RpcSecurityPolicy(),
})

Creates a paired client/server frame channel over in-memory byte streams.

Implementation

static (RpcFrameMultiplexedChannel, RpcFrameMultiplexedChannel) pair({
  RpcSecurityPolicy policy = const RpcSecurityPolicy(),
}) {
  final c2s = StreamController<Uint8List>();
  final s2c = StreamController<Uint8List>();

  final clientChannel = _PairedByteChannel(output: c2s, input: s2c.stream);
  final serverChannel = _PairedByteChannel(output: s2c, input: c2s.stream);

  return (
    RpcFrameMultiplexedChannel(
      channel: clientChannel,
      isClient: true,
      policy: policy,
    ),
    RpcFrameMultiplexedChannel(
      channel: serverChannel,
      isClient: false,
      policy: policy,
    ),
  );
}