Peer.withoutJson constructor

Peer.withoutJson(
  1. StreamChannel _channel,
  2. {ErrorCallback onUnhandledError,
  3. bool strictProtocolChecks: true}
)

Creates a Peer that communicates using decoded messages over channel.

Unlike new Peer, this doesn't read or write JSON strings. Instead, it reads and writes decoded maps or lists.

Note that the peer won't begin listening to channel until Peer.listen is called.

Unhandled exceptions in callbacks will be forwarded to onUnhandledError. If this is not provided, unhandled exceptions will be swallowed.

If strictProtocolChecks is false, the underlying Server will accept some requests which are not conformant with the JSON-RPC 2.0 specification. In particular, requests missing the jsonrpc parameter will be accepted.

Implementation

Peer.withoutJson(this._channel,
    {ErrorCallback onUnhandledError, bool strictProtocolChecks = true}) {
  _server = Server.withoutJson(
      StreamChannel(_serverIncomingForwarder.stream, _channel.sink),
      onUnhandledError: onUnhandledError,
      strictProtocolChecks: strictProtocolChecks);
  _client = Client.withoutJson(
      StreamChannel(_clientIncomingForwarder.stream, _channel.sink));
}