How to use the mdns.createAdvertisement 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 DefinitelyTyped / DefinitelyTyped / mdns / mdns-tests.ts View on Github external
});

browser.start();

var r0 = mdns.tcp('http')                     // string form: _http._tcp
    , r1 = mdns.udp('osc', 'api-v1')            // string form: _osc._udp,_api-v1
    , r2 = new mdns.ServiceType('http', 'tcp')  // string form: _http._tcp
    , r3 = mdns.makeServiceType('https', 'tcp') // string form: _https._tcp
    ;

var txt_record = {
    name: 'bacon'
    , chunky: true
    , strips: 5
};
var ad:MDNS.Advertisement = mdns.createAdvertisement(mdns.tcp('http'), 4321, {txtRecord: txt_record});

var sequence = [
    mdns.rst.DNSServiceResolve()
    , mdns.rst.DNSServiceGetAddrInfo({families: [4] })
];

var browser = mdns.createBrowser(mdns.tcp('http'), {resolverSequence: sequence});

interface HammerTimeService extends MDNS.Service {
    hammerTime:Date;
}

function MCHammer(options:any) {
    options = options || {};
    return function MCHammer(service:HammerTimeService, next:()=>void) {
        console.log('STOP!');
github emilisto / hook.io-mdns / lib / mdns.js View on Github external
if(err) {
      // FIXME: this should prolly be handled differently
      callback(new Error('Listening failed: ' + err));
    }

    options = options || {};

    var regtype = options['mdns-regtype'] || defaults['mdns-regtype'];
    var port = self['hook-port'];

    var _options = {};
    if(options['mdns-name']) _options['name'] = options['mdns-name'];
    if(options['mdns-domain']) _options['domain'] = options['mdns-domain'];
    if(options['mdns-host']) _options['host'] = options['mdns-host'];

    var ad = mdns.createAdvertisement(
      regtype, port, options
    );
    ad.start();

    // FIXME: Check so that advertisement was successful

    if(callback) callback.apply(null, arguments);
  });
github DefinitelyTyped / DefinitelyTyped / mdns / mdns-tests.ts View on Github external
function createAdvertisement() {
    try {
        ad = mdns.createAdvertisement(mdns.tcp('http'), 1337);
        ad.on('error', handleError);
        ad.start();
    } catch (ex) {
        handleError(ex);
    }
}
github spacebro / spacebro / server.js View on Github external
const mdns = require('mdns')
const colors = require('colors')
const shortid = require('shortid')
const pathHelper = require('path')
const config = require('./config.json')
const imagemagick = require('imagemagick-native')
let io = require('socket.io')(config.server.port)
let triggers = ['#supermarche', '#appartement-shazam', '#appartement-mi-temps', '#dans-la-ville', '#fan-zone-precommande', '#fan-zone-selfie', '#bar']

let triggersA = _.map(triggers, function (n) { return 'A' + n })
let triggersB = _.map(triggers, function (n) { return 'B' + n })
triggers = triggers.concat(triggersA).concat(triggersB)

console.log('server.js - listening on port', config.server.port)

var ad = mdns.createAdvertisement(mdns.tcp(config.server.serviceName), config.server.port)
ad.start()

io.on('connection', function (socket) {
  console.log('connection'.bold.green)
  socket
    .on('disconnect', function () {
      console.log('disconnect'.bold.red)
    })
    .on('error', function (err) {
      console.log('server.js - socket error: %s'.bold.red, err)
    })
    .on('write-img', function (imgDataURL) {
      let base64Data = imgDataURL.replace(/^data:image\/png;base64,/, '')
      let name = shortid.generate() + '.png'
      let path = config.image.path.final
      let tmpPath = config.image.path.tmp
github jansmolders86 / mediacenterjs / lib / utils / airplay-server.js View on Github external
server.on('listening', function () {
        advertisment = mdns.createAdvertisement(mdns.tcp('airplay'), port, {name: options.name || "MediaCenterJS", txtRecord: txtrec});
        advertisment.start();
        var raoprec = { et: "0,3,5",
                        cn: "1,2,3",
                        da: "true",
                        sf: "0x4",
                        tp: "UDP",
                        vv: "1",
                        pw: "false",
                        am: SERVER_MODEL,
                        txtvers: "1",
                        vn: "65537",
                        md: "0,1,2",
                        vs: "150.33",
                        sv: "false",
                        ch: "2",
                        sr: "44100",
github node-red / node-red-nodes / io / mdns / mdns.js View on Github external
this.on("input", function(msg) {
            if (msg.payload == false) {
                this.stop();
            }
            else {
                var service = node.service || msg.service;
                var port = Number(node.port || msg.port);
                var options = {};
                if (node.name || msg.name) {
                    options.name = (node.name || msg.name).replace(/\%h/g, os.hostname());
                }
                if (node.txt || msg.txtRecord) { options.txtRecord = node.txt || msg.txtRecord }
                this.stop();
                node.ad = mdns.createAdvertisement(service, port, options);
                node.ad.start();
                node.status({fill: "green", shape: "dot"});
            }
        });
github stephen / nodetunes / lib / server.js View on Github external
this.netServer = net.createServer(this.rtspServer.connectHandler.bind(this.rtspServer)).listen(port, function() {

      var ad = mdns.createAdvertisement(mdns.tcp('raop'), port, {
        name: this.options.macAddress + '@' + this.options.serverName,
        txtRecord: this.txtSetup,
      });

      if (callback) {
        callback(null, {
          port: port,
          macAddress: this.options.macAddress,
        });

      }

      debug('broadcasting mdns advertisement (for port %s)', port);

    }.bind(this));
  }.bind(this));
github citelab / JAMScript / lib / jdiscovery / mdnsregistry.js View on Github external
MDNSRegistry.prototype._createAdvertisementWithRetries = function(self, attr, adName, txtRecord, retries) {
    var ad = mdns.createAdvertisement(mdns.tcp(adName), self.port, {name: this.id, txtRecord: txtRecord}, function(err, service) {
        if (err) {
            self._handleError(self, err, ad, attr, adName, txtRecord, retries);
        } else {
            self.ads[attr] = ad;
        }
    });
    ad.start();
}