Skip to content

Commit

Permalink
support for multiple calls the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Louis Schrumpf authored and Tim Louis Schrumpf committed Jan 16, 2018
1 parent 921276c commit d7fa2f1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ function mainController(sys, familyCode, switchCode, onOff){
returnCode = 404;
}
console.log("Sending Code " + code +" now...");
rfEmitter.sendCode(code, function(error, stdout) { //Send 1234
if(!error) console.log(stdout); //Should display 1234
});
sleep(100, function(){rfEmitter.sendCode(code);});
return returnCode;

}else {
Expand Down Expand Up @@ -149,3 +147,12 @@ function replaceOnes(string,inverted){
}
return result;
}

// sleep for multiple Calls by a e.g. a scene
function sleep(time, callback) {
var stop = new Date().getTime();
while(new Date().getTime() < stop + time) {
;
}
callback();
}

0 comments on commit d7fa2f1

Please sign in to comment.