|
50 | 50 | var ipre = iparts.slice(0,i).join('.') |
51 | 51 | if (ipre == pre) { |
52 | 52 | match = this.interfaces[j].address |
| 53 | + console.clog("UPNP","selected internal address",match) |
53 | 54 | return match |
54 | 55 | } |
55 | 56 | } |
|
71 | 72 | }.bind(this) ) |
72 | 73 | }, |
73 | 74 | onSearchStop: function(info) { |
| 75 | + console.clog('UPNP', "search stop") |
74 | 76 | this.searching = false |
75 | | - this.getIP( function() { |
| 77 | + this.getIP( function(gotIP) { |
| 78 | + if (! gotIP) { return this.allDone(false) } |
76 | 79 | this.getMappings( function(mappings) { |
| 80 | + if (! mappings) { return this.allDone(false) } |
77 | 81 | // check if already exists nice mapping we can use. |
78 | 82 | var internal = this.getInternalAddress() |
79 | 83 | console.clog('UPNP','got current mappings',mappings,'internal address',internal) |
|
225 | 229 | var info = infos[i] |
226 | 230 | info.device.runService(info.service,'GetExternalIPAddress',[],oneResult.bind(this, info)) |
227 | 231 | } |
| 232 | + } else { |
| 233 | + callback(null) |
228 | 234 | } |
229 | 235 | } |
230 | 236 | } |
|
275 | 281 | }, |
276 | 282 | getDescription: function(callback) { |
277 | 283 | var xhr = new WSC.ChromeSocketXMLHttpRequest |
278 | | - //console.clog('UPNP','query',this.description_url) |
| 284 | + console.clog('UPNP','query',this.description_url) |
279 | 285 | xhr.open("GET",this.description_url) |
280 | 286 | xhr.setRequestHeader('connection','close') |
281 | 287 | xhr.responseType = 'xml' |
|
374 | 380 | chrome.sockets.udp.close(parseInt(socketId)) |
375 | 381 | } |
376 | 382 | this.sockMap = {} |
| 383 | + chrome.sockets.udp.onReceive.removeListener( this._onReceive ) |
| 384 | + chrome.sockets.udp.onReceiveError.removeListener( this._onReceive ) |
377 | 385 | }, |
378 | 386 | stopsearch: function() { |
379 | 387 | console.clog('UPNP', "stopping ssdp search") |
380 | 388 | // stop searching, kill all sockets |
381 | 389 | this.searching = false |
382 | 390 | this.cleanup() |
383 | 391 | this.trigger('stop') |
384 | | - chrome.sockets.udp.onReceive.removeListener( this._onReceive ) |
385 | | - chrome.sockets.udp.onReceiveError.removeListener( this._onReceive ) |
386 | 392 | }, |
387 | 393 | search: function(opts) { |
388 | 394 | if (this.searching) { return } |
|
0 commit comments