How to use the mdns.Advertisement function in mdns

To help you get started, we’ve selected a few mdns examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dermike / slide-beacon-app / main.js View on Github external
return new Promise((resolve, reject) => {
    try {
      let urlParts = url.split('/'),
        protocol = urlParts[0].replace(':', ''),
        port = protocol === 'https' ? 443 : 80,
        host = urlParts[2],
        path = urlParts.filter((part, i) => {
          return i > 2 ? part : false;
        }).join('/');
      mdnsAd = new mdns.Advertisement(mdns.tcp(protocol), port, {
        'name': url,
        'txtRecord': {
          'path': path
        },
        'host': host,
        'domain': 'local',
        'ip': host
      });
      mdnsAd.start();
      activeModes += '<span class="modes">mDNS</span>';
      mainWindow.webContents.send('status', [`${url} ${activeModes}`, 'Broadcasting', true]);
      console.log(`mdns broadcasting: ${url}`);
      if (ws) {
        ws.send(`mdns broadcasting: ${url}`);
      }
      resolve();