Class: Messenger

Messenger

Represents and duplex stream for dispatching messages to a given transport adapter and receiving messages to process through middleware stacks

new Messenger( [options])

Parameters:
Name Type Argument Description
options object <optional>
Properties
Name Type Argument Description
serializer Messenger~serializer <optional>
Serializer function
deserializer Messenger~deserializer <optional>
Deserializer function
Source:

Methods


<static> JsonRpcDeserializer(rawMessage, callback)

Parameters:
Name Type Description
rawMessage buffer Incoming message as buffer
callback function Transform stream callback(err, data)
Source:

<static> JsonRpcSerializer(data, sender, receiver, callback)

Parameters:
Name Type Description
data array Object to transform
Properties
Name Type Description
0 object JSON payload, parsed into an object
sender Bucket~contact Origin peer for message
receiver Bucket~contact Destination peer for message
callback function Transform stream callback(err, data)
Source:

<inner> deserializer(data, encoding, callback)

Parameters:
Name Type Description
data object | buffer Incoming message buffer or parsed JSON data
encoding string | null Encoding of incoming data
callback Messenger~deserializerCallback
Source:

<inner> serializer(data, encoding, callback)

Parameters:
Name Type Description
data object | buffer Outgoing message buffer or parsed JSON data
encoding string | null Encoding of incoming data
callback Messenger~serializerCallback
Source:

Type Definitions


deserializerCallback(error, data)

Parameters:
Name Type Description
error error | null
data buffer | object Deserialized data to pass through middleware
Source:

serializerCallback(error, data)

Parameters:
Name Type Description
error error | null
data buffer | object Serialized data to pass through middleware
Source: