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')
6
6
7
7
module . exports = Bonjour
8
8
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 )
12
12
this . _registry = new Registry ( this . _server )
13
13
}
14
14
Original file line number Diff line number Diff line change @@ -7,11 +7,14 @@ var deepEqual = require('deep-equal')
7
7
8
8
module . exports = Server
9
9
10
- function Server ( opts ) {
10
+ function Server ( opts , cbQueryRespond ) {
11
11
this . mdns = multicastdns ( opts )
12
12
this . mdns . setMaxListeners ( 0 )
13
13
this . registry = { }
14
14
this . mdns . on ( 'query' , this . _respondToQuery . bind ( this ) )
15
+ this . cbQueryRespond = typeof cbQueryRespond == 'function'
16
+ ? cbQueryRespond
17
+ : function ( err ) { if ( err ) throw err }
15
18
}
16
19
17
20
Server . prototype . register = function ( records ) {
@@ -83,9 +86,7 @@ Server.prototype._respondToQuery = function (query) {
83
86
} )
84
87
}
85
88
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 )
89
90
} )
90
91
}
91
92
You can’t perform that action at this time.
0 commit comments