Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
fix: stop mdns browser as soon as possible, timeout is last resort
Browse files Browse the repository at this point in the history
  • Loading branch information
apexad committed Apr 8, 2021
1 parent 1a58370 commit c3c611e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/platformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,22 @@ export default class ExamplePlatformAccessory {
if (data.txt.includes('model=AirPort10,115') && foundSerialNumber && this.serialNumber === foundSerialNumber) {
this.platform.log.debug(`txt record contents: ${data.txt}`)
this.setMediaState(this.convertMediaState(data.txt));
mdnsBrowser.stop();
}
}
} catch(error) {
this.platform.log.error(`Error in mDNS check, found invalid record`);
this.platform.log.debug(error);
mdnsBrowser.stop();
}
setTimeout(() => mdnsBrowser.stop(), 5000);
setTimeout(() => {
try {
// make sure mdnsBrowser was stopped if it was not stopped above
mdnsBrowser.stop();
} catch(err) {
this.platform.log.debug(`mdns browser for stop via timeout error: ${err}`);
}
}, 5000);
});
}

Expand Down

0 comments on commit c3c611e

Please sign in to comment.