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

ConnectAPI: made checking local optional

This commit is contained in:
peteruithoven 2014-05-07 17:12:58 +02:00
parent 79e201c3ff
commit b533b28e00

View File

@ -16,6 +16,8 @@ function ConnectAPI() {
this.boxDisapeared; // a box disappeared this.boxDisapeared; // a box disappeared
//this.boxUpdated; // a box is updated / changed //this.boxUpdated; // a box is updated / changed
this.checkLocal = true; // check for wired and access point boxes
var _apiURL = "http://connect.doodle3d.com/api"; var _apiURL = "http://connect.doodle3d.com/api";
var _networkAPI = new NetworkAPI(); var _networkAPI = new NetworkAPI();
var _timeoutTime = 3000; var _timeoutTime = 3000;
@ -80,7 +82,9 @@ function ConnectAPI() {
_self.list(function(foundBoxes) { _self.list(function(foundBoxes) {
//console.log(" foundBoxes: ",foundBoxes); //console.log(" foundBoxes: ",foundBoxes);
foundBoxes.push(_wiredBox); // always check for a wired box if(_self.checkLocal) {
foundBoxes.push(_wiredBox); // check for a wired box
}
updateList(foundBoxes); updateList(foundBoxes);
if(_running) { if(_running) {
clearTimeout(_refreshDelay); clearTimeout(_refreshDelay);
@ -88,13 +92,15 @@ function ConnectAPI() {
} }
}, function() { }, function() {
console.log("ConnectAPI list retrieve failed"); console.log("ConnectAPI list retrieve failed");
// if web is not accessible try to find a box as an accesspoint if(_self.checkLocal) {
// if not found, we look for a wired box // if web is not accessible try to find a box as an accesspoint
_networkAPI.alive(_apBox.localip,_boxTimeoutTime,function() { // if not found, we look for a wired box
updateList([_apBox]); _networkAPI.alive(_apBox.localip,_boxTimeoutTime,function() {
}, function() { updateList([_apBox]);
updateList([_wiredBox]); }, function() {
}); updateList([_wiredBox]);
});
}
if(_running) { if(_running) {
clearTimeout(_refreshDelay); clearTimeout(_refreshDelay);
_refreshDelay = setTimeout(_self.refresh, _refreshInterval); _refreshDelay = setTimeout(_self.refresh, _refreshInterval);