Test timeout to kill phantom viewers

This commit is contained in:
yflory
2019-01-30 15:49:45 +01:00
parent d989b6d6e4
commit cb89a5fdfe
2 changed files with 17 additions and 12 deletions

View File

@@ -1277,6 +1277,7 @@ define([
}
store.cursor.removeClient(clientId);
store.onlyoffice.removeClient(clientId);
Object.keys(Store.channels).forEach(function (chanId) {
var chanIdx = Store.channels[chanId].clients.indexOf(clientId);
if (chanIdx !== -1) {
@@ -1592,7 +1593,6 @@ define([
broadcast([], 'NETWORK_RECONNECT', {myId: info.myId});
});
/*
// Ping clients regularly to make sure one tab was not closed without sending a removeClient()
// command. This allow us to avoid phantom viewers in pads.
var PING_INTERVAL = 30000;
@@ -1609,24 +1609,22 @@ define([
clients.forEach(function (cId) {
var nb = 0;
var ping = function () {
nb++;
if (nb >= MAX_FAILED_PING) {
Store._removeClient(cId);
postMessage(cId, 'TIMEOUT');
console.error('TIMEOUT 5 errors');
console.error('TIMEOUT', cId);
return;
}
nb++;
var to = setTimeout(ping, MAX_PING);
console.log('ping');
postMessage(cId, 'PING', null, function () {
console.log('pong');
postMessage(cId, 'PING', null, function (err) {
if (err) { console.error(err); }
clearTimeout(to);
});
};
ping();
});
}, PING_INTERVAL);
*/
};