Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ciao as default advertiser #1066

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to `hap-nodejs` will be documented in this file. This project tries to adhere to [Semantic Versioning](http://semver.org/).

## Next Release

### Changes

- Set `Ciao` as the default Advertiser

## v1.0.0 (2024-07-10)

### Breaking Changes
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1186,19 +1186,19 @@ export class Accessory extends EventEmitter {
// create our Advertiser which broadcasts our presence over mdns
const parsed = Accessory.parseBindOption(info);

let selectedAdvertiser = info.advertiser ?? MDNSAdvertiser.BONJOUR;
info.advertiser ??= MDNSAdvertiser.CIAO;
if (
(info.advertiser === MDNSAdvertiser.AVAHI && !await AvahiAdvertiser.isAvailable()) ||
(info.advertiser === MDNSAdvertiser.RESOLVED && !await ResolvedAdvertiser.isAvailable())
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test should be against selectedAdvertiser, not the info block, or use the nullish coalescing assignment operator and refactor slightly:

info.advertiser ??= MDNSAdvertiser.CIAO;

Then you can eliminate declaring and using selectedAdvertiser altogether.

console.error(
`[${this.displayName}] The selected advertiser, "${info.advertiser}", isn't available on this platform. ` +
`Reverting to "${MDNSAdvertiser.BONJOUR}"`,
`Reverting to "${MDNSAdvertiser.CIAO}"`,
);
selectedAdvertiser = MDNSAdvertiser.BONJOUR;
info.advertiser = MDNSAdvertiser.CIAO;
}

switch (selectedAdvertiser) {
switch (info.advertiser) {
case MDNSAdvertiser.CIAO:
this._advertiser = new CiaoAdvertiser(this._accessoryInfo, {
interface: parsed.advertiserAddress,
Expand Down
Loading