Remove unnecessary setTimeout

This commit is contained in:
Luc Didry 2015-10-11 13:03:36 +02:00 committed by Luc Didry
parent cc5f4d26d3
commit 4feff52664
1 changed files with 8 additions and 16 deletions

View File

@ -51,10 +51,8 @@ function spawnWebsocket(pa) {
ws.onclose = function() {
console.log('Connection is closed');
if (!window.completed) {
console.log('Connection closed. Retrying to get slice '+pa+' in 5 seconds');
setTimeout(function() {
window.ws = spawnWebsocket(pa);
}, 5000);
console.log('Connection closed. Retrying to get slice '+pa);
window.ws = spawnWebsocket(pa);
}
}
ws.onmessage = function(e) {
@ -96,17 +94,13 @@ function spawnWebsocket(pa) {
window.ws.onclose = function() {
console.log('Connection is closed');
if (!window.completed) {
console.log('Connection closed. Retrying to get slice '+(data.part + 1)+' in 5 seconds');
setTimeout(function() {
window.ws = spawnWebsocket(data.part + 1);
}, 5000);
console.log('Connection closed. Retrying to get slice '+(data.part + 1));
window.ws = spawnWebsocket(data.part + 1);
}
}
window.ws.onerror = function() {
console.log('Error. Retrying to get slice '+(data.part + 1)+' in 5 seconds');
setTimeout(function() {
window.ws = spawnWebsocket(data.part + 1);
}, 5000);
console.log('Error. Retrying to get slice '+(data.part + 1));
window.ws = spawnWebsocket(data.part + 1);
};
window.ws.send('{"part":'+(data.part + 1)+'}');
}
@ -122,10 +116,8 @@ function spawnWebsocket(pa) {
}
}
ws.onerror = function() {
console.log('Error. Retrying to get slice '+pa+' in 5 seconds');
setTimeout(function() {
window.ws = spawnWebsocket(pa);
}, 5000);
console.log('Error. Retrying to get slice '+pa);
window.ws = spawnWebsocket(pa);
}
return ws;
}