Constructor
new MessageBus()
Create a new MessageBus
. This constructor is not to be called directly.
Use dbus.sessionBus()
or dbus.systemBus()
to set up the connection to
the bus.
- Source:
Example
const dbus = require('dbus-next');
const bus = dbus.sessionBus();
// get a proxy object
let obj = await bus.getProxyObject('org.freedesktop.DBus', '/org/freedesktop/DBus');
// request a well-known name
await bus.requestName('org.test.name');
Members
name :string
The unique name of the bus connection. This will be null
until the
MessageBus
is connected.
Type:
- string
- Source:
Methods
addMethodHandler(fn)
Add a user method return handler. Remove the handler with MessageBus#removeMethodHandler
Parameters:
Name | Type | Description |
---|---|---|
fn |
methodHandler | A function to handle a Message of type
MessageType.METHOD_RETURN. Takes the |
- Source:
call(msg) → {Promise}
Send a Message of type MessageType.METHOD_CALL to the bus and wait for the reply.
Parameters:
Name | Type | Description |
---|---|---|
msg |
Message | The message to send. |
- Source:
Returns:
reply - A Promise
that resolves to the Message which is a reply to the call.
- Type
- Promise
Example
let message = new Message({
destination: 'org.freedesktop.DBus',
path: '/org/freedesktop/DBus',
interface: 'org.freedesktop.DBus',
member: 'ListNames'
});
let reply = await bus.call(message);
disconnect()
Disconnect this MessageBus
from the bus.
- Source:
export(path, iface)
Export an Interface
on the bus. See
the documentation for that class for how to define service interfaces.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The object path to export this |
iface |
module:interface~Interface | The service interface to export. |
- Source:
getProxyObject(name, path, xmlopt) → {Promise}
Get a ProxyObject on the bus for the given name and path for interacting
with a service as a client. The proxy object contains a list of the
ProxyInterface
s exported at the name and object path as well as a list
of node
s.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | the well-known name on the bus. |
|
path |
string | the object path exported on the name. |
|
xml |
string |
<optional> |
xml introspection data. |
- Source:
Returns:
- a Promise that resolves with the
ProxyObject
.
- Type
- Promise
newSerial() → {int}
Get a new serial for this bus. These can be used to set the Message#serial member to send the message on this bus.
- Source:
Returns:
- A new serial for this bus.
- Type
- int
releaseName() → {Promise}
Release this name. Requests that the name should no longer be owned by the MessageBus.
- Source:
Returns:
A Promise that will resolve with the ReleaseNameReply.
- Type
- Promise
removeMethodHandler(fn)
Remove a user method return handler that was previously added with MessageBus#addMethodHandler.
Parameters:
Name | Type | Description |
---|---|---|
fn |
methodHandler | A function that was previously added as a method handler. |
- Source:
requestName(name, flags) → {Promise}
Request a well-known name on the bus.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the well-known name on the bus to request. |
flags |
NameFlag | DBus name flags which affect the behavior of taking the name. |
- Source:
- See:
Returns:
- a Promise that resolves with the RequestNameReply.
- Type
- Promise
send(msg)
Send a Message on the bus that does not expect a reply.
Parameters:
Name | Type | Description |
---|---|---|
msg |
Message | The message to send. |
- Source:
Example
let message = Message.newSignal('/org/test/path/,
'org.test.interface',
'SomeSignal');
bus.send(message);
unexport(path, ifaceopt)
Unexport an Interface
on the bus. The interface will no longer be
advertised to clients.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | The object path on which to unexport. |
|
iface |
module:interface~Interface |
<optional> |
The |
- Source: