|
|
@@ -35,14 +35,12 @@ |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function init(time) { |
|
|
|
function init() { |
|
|
|
post("/webevents/register", function(err, res) { |
|
|
|
|
|
|
|
// Retry on error |
|
|
|
if (err) { |
|
|
|
console.error(err); |
|
|
|
time = time || 1000; |
|
|
|
setTimeout(function() { init(time * 2) }, time); |
|
|
|
setTimeout(function() { init() }, 2000); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@@ -51,14 +49,17 @@ |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function await(time) { |
|
|
|
function await() { |
|
|
|
post("/webevents/await/"+key, function(err, res) { |
|
|
|
|
|
|
|
// Retry registering on error |
|
|
|
if (err) { |
|
|
|
// Retry on error |
|
|
|
if (err === "ENOTREGISTERED") { |
|
|
|
console.log("Not registered, reregistering"); |
|
|
|
setTimeout(function() { init() }, 2000); |
|
|
|
return; |
|
|
|
} else if (err) { |
|
|
|
console.error(err); |
|
|
|
time = time || 1000; |
|
|
|
setTimeout(function() { init(time * 2) }, time); |
|
|
|
setTimeout(function() { await() }, 2000); |
|
|
|
return; |
|
|
|
} |
|
|
|
|