(dictionary = {}, callback)
| 38 | |
| 39 | class MDNS extends Socket { |
| 40 | constructor(dictionary = {}, callback) { |
| 41 | super({kind: "UDP", port: MDNS.PORT, multicast: MDNS.IP}); |
| 42 | |
| 43 | this.services = []; |
| 44 | this.monitors = []; |
| 45 | this.client = callback ?? function() {}; |
| 46 | |
| 47 | if (dictionary.hostName) { |
| 48 | this.hostName = dictionary.hostName; |
| 49 | this.hostNameLower = this.hostName.toLowerCase(); |
| 50 | this.probing = 1; |
| 51 | Timer.set(() => this.probe(), 0); |
| 52 | } |
| 53 | } |
| 54 | close() { |
| 55 | while (this.services.length) |
| 56 | this.remove(this.services[0]); |