Browse Source

Try to reconnect if the page was inactive and the WS closed by the browser

pull/856/head
Timothée Jaussoin 6 years ago
parent
commit
82dd3dd44e
  1. 10
      public/scripts/movim_websocket.js

10
public/scripts/movim_websocket.js

@ -61,8 +61,7 @@ var MovimWebsocket = {
var uri = 'ws:' + BASE_URI + 'ws/';
}
if (this.connection
&& this.connection.readyState == 1) {
if (typeof this.connection === 'object') {
this.connection.onclose = null;
this.connection.close();
}
@ -275,3 +274,10 @@ document.addEventListener("DOMContentLoaded", function(event) {
// And we start it
MovimWebsocket.init();
});
// If the Websocket was closed after some innactivity, we try to reconnect
window.addEventListener('focus', function() {
if (MovimWebsocket.connection.readyState > 1) {
MovimWebsocket.init();
}
});
Loading…
Cancel
Save