Remove unnecessary setTimeout
This commit is contained in:
parent
cc5f4d26d3
commit
4feff52664
|
@ -51,10 +51,8 @@ function spawnWebsocket(pa) {
|
||||||
ws.onclose = function() {
|
ws.onclose = function() {
|
||||||
console.log('Connection is closed');
|
console.log('Connection is closed');
|
||||||
if (!window.completed) {
|
if (!window.completed) {
|
||||||
console.log('Connection closed. Retrying to get slice '+pa+' in 5 seconds');
|
console.log('Connection closed. Retrying to get slice '+pa);
|
||||||
setTimeout(function() {
|
window.ws = spawnWebsocket(pa);
|
||||||
window.ws = spawnWebsocket(pa);
|
|
||||||
}, 5000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ws.onmessage = function(e) {
|
ws.onmessage = function(e) {
|
||||||
|
@ -96,17 +94,13 @@ function spawnWebsocket(pa) {
|
||||||
window.ws.onclose = function() {
|
window.ws.onclose = function() {
|
||||||
console.log('Connection is closed');
|
console.log('Connection is closed');
|
||||||
if (!window.completed) {
|
if (!window.completed) {
|
||||||
console.log('Connection closed. Retrying to get slice '+(data.part + 1)+' in 5 seconds');
|
console.log('Connection closed. Retrying to get slice '+(data.part + 1));
|
||||||
setTimeout(function() {
|
window.ws = spawnWebsocket(data.part + 1);
|
||||||
window.ws = spawnWebsocket(data.part + 1);
|
|
||||||
}, 5000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.ws.onerror = function() {
|
window.ws.onerror = function() {
|
||||||
console.log('Error. Retrying to get slice '+(data.part + 1)+' in 5 seconds');
|
console.log('Error. Retrying to get slice '+(data.part + 1));
|
||||||
setTimeout(function() {
|
window.ws = spawnWebsocket(data.part + 1);
|
||||||
window.ws = spawnWebsocket(data.part + 1);
|
|
||||||
}, 5000);
|
|
||||||
};
|
};
|
||||||
window.ws.send('{"part":'+(data.part + 1)+'}');
|
window.ws.send('{"part":'+(data.part + 1)+'}');
|
||||||
}
|
}
|
||||||
|
@ -122,10 +116,8 @@ function spawnWebsocket(pa) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ws.onerror = function() {
|
ws.onerror = function() {
|
||||||
console.log('Error. Retrying to get slice '+pa+' in 5 seconds');
|
console.log('Error. Retrying to get slice '+pa);
|
||||||
setTimeout(function() {
|
window.ws = spawnWebsocket(pa);
|
||||||
window.ws = spawnWebsocket(pa);
|
|
||||||
}, 5000);
|
|
||||||
}
|
}
|
||||||
return ws;
|
return ws;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue