How to use the mdns.udp 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
ad.start();

var browser = mdns.createBrowser(mdns.tcp('http'));

browser.on('serviceUp', function(service:MDNS.Service) {
    console.log("service up: ", service);
});
browser.on('serviceDown', function(service:MDNS.Service) {
    console.log("service down: ", service);
});

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] })
];
github gibber-cc / gibber / js / node / control.js View on Github external
}
	        }
	    }
	}
	console.log("MY IP = ", myIP);
	return addresses[0];
})();

// can't have double quotes sent to Control... double quotes are the default for JSON stringify
function stringify(string) {
	var s = JSON.stringify(string);
	s = s.replace(/\"/g, "'");
	return s;
}

var browser = mdns.createBrowser(mdns.udp('osc'));

browser.on('serviceUp', function(service) {
	console.log(service);
	control = new osc.UdpSender(service.host, 8080);
	control.send( '/control/createBlankInterface', 'ss', ['testing', 'portrait'] );
	control.send( "/control/pushDestination", 's', [myIP + ":" + 8081] );	
});

browser.on('serviceDown', function(service) { console.log("service down: ", service); });
browser.start();

var receiver = new osc.UdpReceiver(8081);
receiver.on('', function(e) {
	console.log(e);
	gibber.emit('OSC', {path:e.path, tags:e.typetag, params:e.params});
});
github gibber-cc / gibber / js / node / republicish.js View on Github external
socket.on('joinRepublic', function(userName) {
        console.log(userName, 'joins the republic');
        me = userName;
        if (ad) {
            ad.stop();
        }
        for (var key in fief) {
            if (key !== me) {
                socket.emit('addUser', key);
            }
        }
        ad = mdns.createAdvertisement(mdns.udp('osc'), port, {
            txtRecord: {
                name: me,
            }
        });
        ad.start();
    });
github gibber-cc / gibber / js / node / republicish.js View on Github external
console.log('got osc/udp message:', message);
    gibber.emit('code', {
        user: message.params[0],
        code: message.params[1],
        codeblockNumber: message.params[2]
    });
});

receiver.on('/claimCode', function(msg) {
    gibber.emit('claimCode', {
        name: msg.params[0],
        codeblockNumber: msg.params[1]
    });
});

var browser = mdns.createBrowser(mdns.udp('osc'));

browser.on('serviceUp', function(service) {
    console.log(service);
    console.log('ad found on', service.host, ':', service.port);

    if (service.txtRecord.name) {
        fief[service.txtRecord.name] = {
            osc: new osc.UdpSender(service.host, service.port),
            name: service.name
        };
        if (gibber) {
            if (service.txtRecord.name !== me) {
                gibber.emit('addUser', service.txtRecord.name);
            }
        }
        console.log('added', service.txtRecord.name);