A module for exporting interfaces on a name on the message bus.
- Source:
Classes
Members
(static, constant) ACCESS_READ
- Source:
(static, constant) ACCESS_READWRITE
Used for Interface
property options to specify that clients have read and
write access to the property.
- Source:
(static, constant) ACCESS_WRITE
- Source:
Methods
(static) method(options)
A decorator function to define an Interface
class member as a method. The method will be
called when the client calls it on the bus with the given arguments with
types specified by the inSignature
in the method options. The method
should return a result specified by the outSignature
which will be
returned to the client over the message bus. If multiple output parameters
are specified in the outSignature
, they should be returned within an
array.
The method may also be async
or return a Promise
with the result and the
reply will be sent once the promise returns with a response body.
The method may throw a DBusError with an error name and message to return the error to the client.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | The options for this method. Properties
|
- Source:
- See:
Example
// uncomment the decorators to use them (jsdoc bug)
class MyInterface extends Interface {
//@method({inSignature: 's', outSignature: 's'})
async Echo(what) {
return what;
}
//@method({inSignature: 'ss', outSignature: 'vv'})
ReturnsMultiple(what, what2) {
return [
new Variant('s', what),
new Variant('s', what2)
];
}
//@method({inSignature: '', outSignature: ''})
ThrowsError() {
// the error is returned to the client
throw new DBusError('org.test.iface.Error', 'something went wrong');
}
}
(static) property(options)
A decorator function to define an Interface
class member as a property. The property will
be gotten and set from the class when users call the standard DBus methods
org.freedesktop.DBus.Properties.Get
,
org.freedesktop.DBus.Properties.Set
, and
org.freedesktop.DBus.Properties.GetAll
. The property getters and setters
may throw a DBusError with an error name and message to return the
error to the client.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | The options for this property. Properties
|
- Source:
- See:
Example
class MyInterface extends Interface {
// uncomment below to use the decorator (jsdoc bug)
//@property({signature: 's'})
get MyProp() {
return this.myProp;
}
set MyProp(value) {
this.myProp = value;
}
}
(static) signal(options)
A decorator function to define an Interface
class member as a signal. To emit the signal on
the bus to listeners, just call the decorated method and the signal will be
emitted with the returned value with types specified by the signature
in
the signal options. If the signal has multiple output parameters, they
should be returned in an array.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | The options for this property. Properties
|
- Source:
- See:
Example
// uncomment the decorators to use them (jsdoc bug)
class MyInterface extends Interface {
//@signal({signature: 's'})
HelloWorld(value) {
return value;
}
//@signal({signature: 'ss'})
SignalMultiple(x) {
return [
'hello',
'world'
];
}
}