hap-nodejs
Advanced tools
Comparing version 1.1.1-alpha.6 to 1.1.1-alpha.7
@@ -198,15 +198,18 @@ import assert from 'node:assert'; | ||
function messageBusConnectionResult(bus) { | ||
debug('messageBusConnectionResult(): Checking DBus connection...'); | ||
return new Promise((resolve, reject) => { | ||
const errorHandler = (error) => { | ||
bus.connection.removeListener('connect', () => { | ||
bus.connection.removeListener('error', errorHandler); | ||
resolve(); | ||
}); | ||
debug('messageBusConnectionResult(): DBus connection failed!'); | ||
// eslint-disable-next-line ts/no-use-before-define | ||
bus.connection.removeListener('connect', connectHandler); | ||
reject(error); | ||
}; | ||
bus.connection.once('connect', () => { | ||
const connectHandler = () => { | ||
debug('messageBusConnectionResult(): DBus connection established!'); | ||
bus.connection.removeListener('error', errorHandler); | ||
resolve(); | ||
}); | ||
}; | ||
bus.connection.once('connect', connectHandler); | ||
bus.connection.once('error', errorHandler); | ||
debug('messageBusConnectionResult(): DBus connection!'); | ||
}); | ||
@@ -234,2 +237,3 @@ } | ||
return new Promise((resolve, reject) => { | ||
debug('dbusInvoke(): Invoking DBus method %s.%s on %s at %s', dbusInterface, member, destination, path); | ||
const command = { | ||
@@ -244,4 +248,8 @@ destination, | ||
.invoke(command) | ||
.then(result => resolve(result)) | ||
.then((result) => { | ||
debug('dbusInvoke(): DBus method %s.%s on %s at %s succeeded: %o', dbusInterface, member, destination, path, result); | ||
resolve(result); | ||
}) | ||
.catch((error) => { | ||
debug('dbusInvoke(): DBus method %s.%s on %s at %s failed: %s', dbusInterface, member, destination, path, error); | ||
reject(new DBusInvokeError(error)); | ||
@@ -402,3 +410,5 @@ }); | ||
try { | ||
debug('Checking Avahi/DBus connection...'); | ||
await messageBusConnectionResult(bus); | ||
debug('Avahi/DBus connection established!'); | ||
} | ||
@@ -410,2 +420,3 @@ catch (error) { | ||
try { | ||
debug('Checking Avahi/DBus interface...'); | ||
const version = await this.avahiInvoke(bus, '/', 'Server', 'GetVersionString'); | ||
@@ -418,2 +429,3 @@ debug('Detected Avahi over DBus interface running version \'%s\'.', version); | ||
} | ||
debug('Avahi/DBus classified available!'); | ||
return true; | ||
@@ -420,0 +432,0 @@ } |
{ | ||
"name": "hap-nodejs", | ||
"type": "module", | ||
"version": "1.1.1-alpha.6", | ||
"version": "1.1.1-alpha.7", | ||
"description": "HAP-NodeJS is a Node.js implementation of HomeKit Accessory Server.", | ||
@@ -6,0 +6,0 @@ "author": "Khaos Tian <khaos.tian@gmail.com> (https://tz.is/)", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2269685
33861