File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,9 @@ var Browser = require('./lib/browser')
66
77module . exports = Bonjour
88
9- function Bonjour ( opts ) {
10- if ( ! ( this instanceof Bonjour ) ) return new Bonjour ( opts )
11- this . _server = new Server ( opts )
9+ function Bonjour ( opts , cbQueryRespond ) {
10+ if ( ! ( this instanceof Bonjour ) ) return new Bonjour ( opts , cbQueryRespond )
11+ this . _server = new Server ( opts , cbQueryRespond )
1212 this . _registry = new Registry ( this . _server )
1313}
1414
Original file line number Diff line number Diff line change @@ -7,11 +7,14 @@ var deepEqual = require('deep-equal')
77
88module . exports = Server
99
10- function Server ( opts ) {
10+ function Server ( opts , cbQueryRespond ) {
1111 this . mdns = multicastdns ( opts )
1212 this . mdns . setMaxListeners ( 0 )
1313 this . registry = { }
1414 this . mdns . on ( 'query' , this . _respondToQuery . bind ( this ) )
15+ this . cbQueryRespond = typeof cbQueryRespond == 'function'
16+ ? cbQueryRespond
17+ : function ( err ) { if ( err ) throw err }
1518}
1619
1720Server . prototype . register = function ( records ) {
@@ -83,9 +86,7 @@ Server.prototype._respondToQuery = function (query) {
8386 } )
8487 }
8588
86- self . mdns . respond ( { answers : answers , additionals : additionals } , function ( err ) {
87- if ( err ) throw err // TODO: Handle this (if no callback is given, the error will be ignored)
88- } )
89+ self . mdns . respond ( { answers : answers , additionals : additionals } , this . cbQueryRespond )
8990 } )
9091}
9192
You can’t perform that action at this time.
0 commit comments