How to use the mdns.makeServiceType 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
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] })
];

var browser = mdns.createBrowser(mdns.tcp('http'), {resolverSequence: sequence});
github luan007 / edge-node-wrt / System / SubSys / Native / mdns.ts View on Github external
private browseService = (service) => {
        var t = service.type;
        if (!t) return;
        var string_ = mdns.makeServiceType(t).toString();
        if (this.manual[string_]) return;
        this.manual[string_] = mdns.createBrowser(t, {
            resolverSequence: [
                mdns.rst.DNSServiceResolve()
            ]
        });
        this.manual[string_].on("serviceUp", this.eventProxy.bind(null, 1));
        this.manual[string_].on("serviceDown", this.eventProxy.bind(null, 0));
        this.manual[string_].on("error",(err) => {
            warn(err);
        });
        this.manual[string_].start();
        trace("STARTING BROWSER - " + string_);
        return this.manual[string_];
    };
github luan007 / edge-node-wrt / System / SubSys / Native / mdns.ts View on Github external
private eventProxy = (event, service) => {
        //trace((event ? "+" : "-") + " " + service.type);
        //trace(service);
        var s = JSON.stringify(service);
        var typeString = mdns.makeServiceType(service.type).toString();

        if (!service.host) {
            return warn("Record is broken, need hostname");
        } 
        dns.lookup(service.host,(err, ip, family) => {
            if (err) return warn(err);
            else {
                info(arguments);
            }

            //if (!ip) return;
            trace((event ? "+" : "-") + " " + service.type + "@" + ip);
            service.addresses = ip;
            var addrs = service.addresses;
            for (var i = 0; i < addrs.length; i++) {
                var addr = addrs[i];
github luan007 / edge-node-wrt / SYS / Common / Native / mdns_.ts View on Github external
private browseService = (service) => {
        var t = service.type;
        if (!t) return;
        var string_ = mdns.makeServiceType(t).toString();
        if (this.manual[string_]) return;
        this.manual[string_] = mdns.createBrowser(t, {
            resolverSequence: [
                mdns.rst.DNSServiceResolve()
            ]
        });
        this.manual[string_].on("serviceUp", this.eventProxy.bind(null, 1));
        this.manual[string_].on("serviceDown", this.eventProxy.bind(null, 0));
        this.manual[string_].on("error",(err) => {
            warn(err);
        });
        this.manual[string_].start();
        trace("STARTING BROWSER - " + string_);
        return this.manual[string_];
    };
github luan007 / edge-node-wrt / SYS / Common / Native / mdns_.ts View on Github external
private eventProxy = (event, service) => {
        //trace((event ? "+" : "-") + " " + service.type);
        //trace(service);
        var s = JSON.stringify(service);
        var typeString = mdns.makeServiceType(service.type).toString();

        if (!service.host) {
            return warn("Record is broken, need hostname");
        } 
        dns.lookup(service.host, (err, ip, family) => {
            if (err) return warn(err);
            else {
                info(err, ip, family);
            }

            //if (!ip) return;
            trace((event ? "+" : "-") + " " + service.type + "@" + ip);
            service.addresses = ip;
            var addrs = Array.isArray(service.addresses) ? service.addresses : [service.addresses];
            for (var i = 0; i < addrs.length; i++) {
                var addr = addrs[i];