0
0
mirror of https://github.com/Doodle3D/doodle3d-connect.git synced 2024-12-26 02:23:48 +01:00

Double check wired box

This commit is contained in:
peteruithoven 2014-05-12 16:54:16 +02:00
parent fdb6a22549
commit 9b06139f85

View File

@ -35,7 +35,7 @@ function ConnectAPI() {
var _numBoxesFound = 0; // count how many boxes responded var _numBoxesFound = 0; // count how many boxes responded
var _boxes = {}; // current list of boxes var _boxes = {}; // current list of boxes
var _numBoxes = 0; // current number of boxes var _numBoxes = 0; // current number of boxes
var _checkedWiredBox = false;
var _self = this; var _self = this;
this.list = function(completeHandler,failedHandler) { this.list = function(completeHandler,failedHandler) {
@ -143,10 +143,22 @@ function ConnectAPI() {
_numBoxesChecking++; _numBoxesChecking++;
_networkAPI.alive(boxData.localip,_boxTimeoutTime,function() { _networkAPI.alive(boxData.localip,_boxTimeoutTime,function() {
addBox(boxData); if(boxData.localip === _wiredBox.localip) {
_numBoxesFound++; // double check wired box (otherwise it shows up on switch to ap)
if(_checkedWiredBox) {
addBox(boxData);
_numBoxesFound++;
}
_checkedWiredBox = true;
} else {
addBox(boxData);
_numBoxesFound++;
}
}, function() { }, function() {
removeBox(boxData.localip); removeBox(boxData.localip);
if(boxData === _wiredBox) {
_checkedWiredBox = false;
}
},function(){ },function(){
_numBoxesChecking--; _numBoxesChecking--;
if(_numBoxesChecking <= 0 && _listChanged && _self.listUpdated) { if(_numBoxesChecking <= 0 && _listChanged && _self.listUpdated) {