Peer class

A JSON-RPC 2.0 client and server.

This supports bidirectional peer-to-peer communication with another JSON-RPC 2.0 endpoint. It sends both requests and responses across the same communication channel and expects to connect to a peer that does the same.

Implemented types

Constructors

Peer(StreamChannel<String> channel, {ErrorCallback? onUnhandledError, bool strictProtocolChecks = true})
Creates a Peer that communicates over channel.
Peer.withoutJson(StreamChannel _channel, {ErrorCallback? onUnhandledError, bool strictProtocolChecks = true})
Creates a Peer that communicates using decoded messages over channel.

Properties

done → Future
Returns a Future that completes when the underlying connection is closed.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
isClosed → bool
Whether the underlying connection is closed.
no setteroverride
onUnhandledError → ErrorCallback?
A callback that is fired on unhandled exceptions.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
strictProtocolChecks → bool
Whether to strictly enforce the JSON-RPC 2.0 specification for received messages.
no setteroverride

Methods

close() → Future
Closes the underlying connection.
override
listen() → Future
Starts listening to the underlying stream.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerFallback(dynamic callback(Parameters parameters)) → void
Registers a fallback method on this server.
override
registerMethod(String name, Function callback) → void
Registers a method named name on this server.
override
sendNotification(String method, [dynamic parameters]) → void
Sends a JSON-RPC 2 request to invoke the given method without expecting a response.
override
sendRequest(String method, [dynamic parameters]) → Future
Sends a JSON-RPC 2 request to invoke the given method.
override
toString() → String
A string representation of this object.
inherited
withBatch(dynamic callback()) → void
Runs callback and batches any requests sent until it returns.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited