mdns-discovery
Advanced tools
Comparing version 0.1.6 to 0.1.7
"use strict"; | ||
var debug = require('debug')('mdns-discovery'); | ||
var dgram = require("dgram"); | ||
var packet = require('dns-packet'); | ||
var debug = require('debug')('mdns-discovery'), | ||
dgram = require("dgram"), | ||
packet = require('dns-packet'); | ||
@@ -25,2 +25,3 @@ var defaultOptions = { | ||
ttl: 64 | ||
//returnOnFirstFound: false, | ||
//find: 'string' | ||
@@ -115,3 +116,2 @@ }; | ||
//client.on("message", this.onMessage.bind(this)); | ||
client.on("message", function(message, rinfo) { | ||
@@ -169,2 +169,3 @@ this.onMessage(message, rinfo); | ||
}.bind(this)); | ||
if (readyCallback) this.readyCallback = readyCallback.bind(this); | ||
if (timeout) this.timer = setTimeout(function() { | ||
@@ -177,3 +178,3 @@ this.close(); | ||
} | ||
readyCallback && readyCallback(this.found); | ||
this.readyCallback && this.readyCallback(this.found); | ||
}.bind(this), timeout * 1000); | ||
@@ -198,2 +199,6 @@ return this; | ||
}); | ||
if (this.options.returnOnFirstFound) { | ||
this.close(); | ||
this.readyCallback(this.found); | ||
} | ||
} | ||
@@ -200,0 +205,0 @@ }.bind(this)); |
{ | ||
"name": "mdns-discovery", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Multicast DNS", | ||
@@ -18,3 +18,3 @@ "author": { | ||
"keywords": [ | ||
"mnds", | ||
"mdns", | ||
"broadcast", | ||
@@ -21,0 +21,0 @@ "datagram", |
@@ -14,5 +14,11 @@ ###mnds Multicast DNS | ||
```js | ||
var Mdns = require('mdns-discovery'); | ||
var mdns = new Mdns({ timeout: 5, name: '_amzn-wplay._tcp.local', find: 'amzn.dmgr:'}); | ||
var mdns = new Mdns({ | ||
timeout: 4, | ||
returnOnFirstFound: true, | ||
name: '_amzn-wplay._tcp.local', | ||
find: 'amzn.dmgr:' | ||
}); | ||
mdns.run (function(res) { | ||
@@ -19,0 +25,0 @@ res.forEach(enry) { |
11474
216
56