Peer constructor

Peer(
  1. StreamChannel<String> channel,
  2. {ErrorCallback? onUnhandledError,
  3. bool strictProtocolChecks = true}
)

Creates a Peer that communicates over channel.

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(StreamChannel<String> channel,
    {ErrorCallback? onUnhandledError, bool strictProtocolChecks = true})
    : this.withoutJson(
          jsonDocument.bind(channel).transform(respondToFormatExceptions),
          onUnhandledError: onUnhandledError,
          strictProtocolChecks: strictProtocolChecks);