implements the dnode protocol abstractly
This module implements the dnode protocol in a reusable form that is presently used for both the server-side and browser-side dnode code.
var proto = ;var s =;var c = ;s;c;c;sstart;cstart;
var protocol =
Create a new protocol object with a constructor
cons and an optional callback
cons should be a function, in which case it will be used to create an instance
new cons(remote, proto) where
remote is an empty reference to the remote
object before being populated and
proto is the protocol instance.
If you return an object in
cons the return value will be used
new does that part).
If you pass in a non-function as
cons, its value will be used as the instance
You can optionally specify
opts.unwrap to wrap and unwrap
remote values for implementing weakmaps or marking callbacks.
The return value of
opts.wrap(cb, id) will be stored in
opts.unwrap(ref, id) will be called with the
ref obtained from
previously to turn
ref back into a
Handle a request object emitted by the request event, calling the method the request mentions with the provided arguments.
Emit a request event for the method id
method and the raw arguments
The args will be scrubbed for callbacks and emitted in normal form suitable for
Begin the methods exchange. All listeners should be bound before this function is called.
Instruct the opposing connection to drop all references to the callback
Emitted when a request is ready to be sent.
The request should be serialized and passed to the opposing connection's
Emitted when the remote reference has been populated.
Emitted when there is a non-fatal failed request.
Emitted when there is a fatal exception one of the local callbacks.
With npm do:
npm install dnode-protocol