Move mDNS initialization (#3412)

master
Mark Haslinghuis 2023-04-10 01:55:24 +02:00 committed by GitHub
parent 5344781de2
commit ef40e88e21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -35,8 +35,7 @@ MdnsDiscovery.initialize = function() {
fqdn: `${service.name}._http._tcp.local.`,
ready: true,
});
}
else if (action === 'added' && service.name.includes("elrs_rx")) {
} else if (action === 'added' && service.name.includes("elrs_rx")) {
//restart zeroconf if service ip doesn't arrive in 1000ms
setTimeout(() => {
if (self.mdnsBrowser.services.length === 0 || self.mdnsBrowser.services.filter(s => s.fqdn === `${service.name}._http._tcp.local.`)[0].ready === false) {
@ -47,6 +46,7 @@ MdnsDiscovery.initialize = function() {
}
});
}
reinit();
} else {
const bonjour = require('bonjour')();

View File

@ -50,6 +50,10 @@ PortHandler.reinitialize = function () {
this.showAllSerialDevices = getConfig('showAllSerialDevices').showAllSerialDevices;
this.useMdnsBrowser = getConfig('useMdnsBrowser').useMdnsBrowser;
if (this.useMdnsBrowser) {
MdnsDiscovery.initialize();
}
this.check(); // start listening, check after TIMEOUT_CHECK ms
};

View File

@ -12,7 +12,6 @@ import PortUsage from "./port_usage";
import PortHandler from "./port_handler";
import CONFIGURATOR, { API_VERSION_1_45, API_VERSION_1_46 } from "./data_storage";
import serial from "./serial";
import MdnsDiscovery from "./mdns_discovery";
import UI_PHONES from "./phones_ui";
import { bit_check } from './bit.js';
import { sensor_status, have_sensor } from "./sensor_helpers";
@ -171,7 +170,6 @@ export function initializeSerialBackend() {
setConfig({'auto_connect': GUI.auto_connect});
});
MdnsDiscovery.initialize();
PortHandler.initialize();
PortUsage.initialize();
}