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. [...]
read-only, override
hashCode int
The hash code for this object. [...]
read-only, inherited
isClosed bool
Whether the underlying connection is closed. [...]
read-only, override
onUnhandledError ErrorCallback
A callback that is fired on unhandled exceptions. [...]
read-only, override
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
strictProtocolChecks bool
Whether to strictly enforce the JSON-RPC 2.0 specification for received messages. [...]
read-only, override

Methods

close() Future
Closes the underlying connection. [...]
override
listen() Future
Starts listening to the underlying stream. [...]
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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
Returns 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