resources/websockets.js in plezi-0.12.1 vs resources/websockets.js in plezi-0.12.2

- old
+ new

@@ -8,12 +8,13 @@ var websocket = NaN // count failed attempts var websocket_fail_count = 0 // to limit failed reconnection attempts, set this to a number. var websocket_fail_limit = NaN +// to offer some space between reconnection attempts, set this interval in miliseconds. +var websocket_reconnect_interval = 250 - function init_websocket() { if(websocket && websocket.readyState == 1) return true; // console.log('no need to renew socket connection'); websocket = new WebSocket(ws_uri); websocket.onopen = function(e) { @@ -31,15 +32,15 @@ // you probably want to reopen the websocket if it closes. if(isNaN(websocket_fail_limit) || (websocket_fail_count <= websocket_fail_limit) ) { // update the count websocket_fail_count += 1; // try to reconect - init_websocket(); + setTimeout( init_websocket, websocket_reconnect_interval); }; }; websocket.onerror = function(e) { // update the count. - websocket_fail_limit += 1 + websocket_fail_count += 1 // what do you want to do now? }; websocket.onmessage = function(e) { // what do you want to do now? console.log(e.data);