mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
Initial commit of WebOS receiver
This commit is contained in:
parent
b7e304b987
commit
90e1f4de1a
118 changed files with 18279 additions and 1746 deletions
39
receivers/common/web/DiscoveryService.ts
Normal file
39
receivers/common/web/DiscoveryService.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import mdns from 'modules/mdns-js';
|
||||
import { Main, getComputerName } from 'src/Main';
|
||||
|
||||
export class DiscoveryService {
|
||||
private serviceTcp: any;
|
||||
private serviceWs: any;
|
||||
|
||||
start() {
|
||||
if (this.serviceTcp || this.serviceWs) {
|
||||
return;
|
||||
}
|
||||
|
||||
const name = `FCast-${getComputerName()}`;
|
||||
// Cannot reference Main during static class initialization
|
||||
// @ts-ignore
|
||||
if (TARGET === 'webOS') {
|
||||
console.log(`Discovery service started: ${name}`);
|
||||
} else {
|
||||
Main.logger.info(`Discovery service started: ${name}`);
|
||||
}
|
||||
|
||||
this.serviceTcp = mdns.createAdvertisement(mdns.tcp('_fcast'), 46899, { name: name });
|
||||
this.serviceTcp.start();
|
||||
this.serviceWs = mdns.createAdvertisement(mdns.tcp('_fcast-ws'), 46898, { name: name });
|
||||
this.serviceWs.start();
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (this.serviceTcp) {
|
||||
this.serviceTcp.stop();
|
||||
this.serviceTcp = null;
|
||||
}
|
||||
|
||||
if (this.serviceWs) {
|
||||
this.serviceWs.stop();
|
||||
this.serviceWs = null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue