How to use the dbus-next.NameFlag function in dbus-next

To help you get started, we’ve selected a few dbus-next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dbusjs / mpris-service / src / index.js View on Github external
if (this.supportedInterfaces.indexOf('player') >= 0) {
    this._addPlayerInterface(this._bus);
  }
  if (this.supportedInterfaces.indexOf('trackList') >= 0) {
    this._addTracklistInterface(this._bus);
  }
  if (this.supportedInterfaces.indexOf('playlists') >= 0) {
    this._addPlaylistsInterface(this._bus);
  }

  for (let k of Object.keys(this.interfaces)) {
    let iface = this.interfaces[k];
    this._bus.export(MPRIS_PATH, iface);
  }

  this._bus.requestName(this.serviceName, dbus.NameFlag.DO_NOT_QUEUE)
    .then((reply) => {
      if (reply === dbus.RequestNameReply.EXISTS) {
        this.serviceName = `${this.serviceName}.instance${process.pid}`;
        return this._bus.requestName(this.serviceName);
      }
    })
    .catch((err) => {
      this.emit('error', err);
    });
};