Class: Message

Message(options)

A Message is a class used for sending and receiving messages through the MessageBus with the low-level api. Messages can be constructed by the user directly for method calls or with the static convenience methods on this class for the other types of messages. Messages can be sent through a connected MessageBus with MessageBus#call for method calls that expect a reply from the server or MessageBus#send for messages that do not expect a reply. See those methods for an example of how to use this class.

Constructor

new Message(options)

Construct a new Message to send on the bus.

Parameters:
Name Type Description
options object

Options to construct this Message with. See the corresponding member for more information.

Properties
Name Type Attributes Default Description
type MessageType <optional>
MessageType.METHOD_CALL
serial int <optional>
destination string <optional>
path string <optional>
interface string <optional>

Required for signals.

member string <optional>

Required for method calls and signals.

signature string <optional>
''
body Array <optional>
[]

Must match the signature.

errorName string <optional>

Must be a valid interface name. Required for errors.

replySerial string <optional>

Required for errors and method returns.

flags MessageFlags <optional>
Source:
See:

Members

body :Array

The body arguments for this message. Must match the signature.

Type:
  • Array
Source:

destination :string

The address on the bus to send the message to.

Type:
  • string
Source:

errorName :string

The name of the error if this is a message of type ERROR. Must be a valid interface name.

Type:
  • string
Source:

flags :MessageFlags

The flags for this message.

Type:
  • MessageFlags
Source:

interface :string

The destination interface for this message.

Type:
  • string
Source:

member :string

The destination member on the interface for this message.

Type:
  • string
Source:

path :string

The name of the object path for the message. Required for method calls and signals.

Type:
  • string
Source:

replySerial :int

The serial for the message this is in reply to. Set for types ERROR and METHOD_RETURN.

Type:
  • int
Source:

sender :string

The name of the bus from which this message was sent. Set by the MessageBus.

Type:
  • string
Source:

serial :int

The serial of the message to track through the bus. You must use MessageBus#newSerial to get this serial. If not set, it will be set automatically when the message is sent.

Type:
  • int
Source:

signature :string

The type signature for the body args.

Type:
  • string
Source:

type :MessageType

The type of message this is.

Type:
Source:

Methods

(static) newError(msg, errorName, errorTextopt)

Construct a new Message of type ERROR in reply to the given Message.

Parameters:
Name Type Attributes Default Description
msg Message

The Message this error is in reply to.

errorName string

The name of the error. Must be a valid interface name.

errorText string <optional>
'An error occurred.'

An error message for the error.

Source:

(static) newMethodReturn(msg, signature, body)

Construct a new Message of type METHOD_RETURN in reply to the given message.

Parameters:
Name Type Description
msg Message

The Message this Message is in reply to.

signature string

The signature for the message body.

body Array

The body of the message as an array of arguments. Must match the signature.

Source:

(static) newSignal(path, iface, signature, {Array)

Construct a new Message of type SIGNAL to broadcast on the bus.

Parameters:
Name Type Description
path string

The object path of this signal.

iface string

The interface of this signal.

signature string

The signature of the message body.

{Array

body - The body of the message as an array of arguments. Must match the signature.

Source: