Test timeout to kill phantom viewers
This commit is contained in:
parent
d989b6d6e4
commit
cb89a5fdfe
@ -1048,17 +1048,22 @@ define([
|
|||||||
cb();
|
cb();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*var onPing = function (data, cb) {
|
var onPing = function (data, cb) {
|
||||||
cb();
|
cb();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var timeout = false;
|
||||||
var onTimeout = function () {
|
var onTimeout = function () {
|
||||||
//alert("Timeout");
|
// XXX
|
||||||
};*/
|
timeout = true;
|
||||||
|
common.onNetworkDisconnect.fire();
|
||||||
|
// FIXME: no UI in outer...
|
||||||
|
alert("Timeout error, please reload this tab");
|
||||||
|
};
|
||||||
|
|
||||||
var queries = {
|
var queries = {
|
||||||
/*PING: onPing,
|
PING: onPing,
|
||||||
TIMEOUT: onTimeout,*/
|
TIMEOUT: onTimeout,
|
||||||
REQUEST_LOGIN: requestLogin,
|
REQUEST_LOGIN: requestLogin,
|
||||||
UPDATE_METADATA: common.changeMetadata,
|
UPDATE_METADATA: common.changeMetadata,
|
||||||
UPDATE_TOKEN: function (data) {
|
UPDATE_TOKEN: function (data) {
|
||||||
@ -1375,6 +1380,7 @@ define([
|
|||||||
console.log('Outer ready');
|
console.log('Outer ready');
|
||||||
Object.keys(queries).forEach(function (q) {
|
Object.keys(queries).forEach(function (q) {
|
||||||
chan.on(q, function (data, cb) {
|
chan.on(q, function (data, cb) {
|
||||||
|
if (timeout) { return; }
|
||||||
try {
|
try {
|
||||||
queries[q](data, cb);
|
queries[q](data, cb);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -1387,6 +1393,7 @@ define([
|
|||||||
|
|
||||||
postMessage = function (cmd, data, cb, opts) {
|
postMessage = function (cmd, data, cb, opts) {
|
||||||
cb = cb || function () {};
|
cb = cb || function () {};
|
||||||
|
if (timeout) { return void cb ({error: 'TIMEOUT'}); }
|
||||||
chan.query(cmd, data, function (err, data) {
|
chan.query(cmd, data, function (err, data) {
|
||||||
if (err) { return void cb ({error: err}); }
|
if (err) { return void cb ({error: err}); }
|
||||||
cb(data);
|
cb(data);
|
||||||
|
|||||||
@ -1277,6 +1277,7 @@ define([
|
|||||||
}
|
}
|
||||||
store.cursor.removeClient(clientId);
|
store.cursor.removeClient(clientId);
|
||||||
store.onlyoffice.removeClient(clientId);
|
store.onlyoffice.removeClient(clientId);
|
||||||
|
|
||||||
Object.keys(Store.channels).forEach(function (chanId) {
|
Object.keys(Store.channels).forEach(function (chanId) {
|
||||||
var chanIdx = Store.channels[chanId].clients.indexOf(clientId);
|
var chanIdx = Store.channels[chanId].clients.indexOf(clientId);
|
||||||
if (chanIdx !== -1) {
|
if (chanIdx !== -1) {
|
||||||
@ -1592,7 +1593,6 @@ define([
|
|||||||
broadcast([], 'NETWORK_RECONNECT', {myId: info.myId});
|
broadcast([], 'NETWORK_RECONNECT', {myId: info.myId});
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
// Ping clients regularly to make sure one tab was not closed without sending a removeClient()
|
// 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.
|
// command. This allow us to avoid phantom viewers in pads.
|
||||||
var PING_INTERVAL = 30000;
|
var PING_INTERVAL = 30000;
|
||||||
@ -1609,24 +1609,22 @@ define([
|
|||||||
clients.forEach(function (cId) {
|
clients.forEach(function (cId) {
|
||||||
var nb = 0;
|
var nb = 0;
|
||||||
var ping = function () {
|
var ping = function () {
|
||||||
nb++;
|
|
||||||
if (nb >= MAX_FAILED_PING) {
|
if (nb >= MAX_FAILED_PING) {
|
||||||
Store._removeClient(cId);
|
Store._removeClient(cId);
|
||||||
postMessage(cId, 'TIMEOUT');
|
postMessage(cId, 'TIMEOUT');
|
||||||
console.error('TIMEOUT 5 errors');
|
console.error('TIMEOUT', cId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
nb++;
|
||||||
var to = setTimeout(ping, MAX_PING);
|
var to = setTimeout(ping, MAX_PING);
|
||||||
console.log('ping');
|
postMessage(cId, 'PING', null, function (err) {
|
||||||
postMessage(cId, 'PING', null, function () {
|
if (err) { console.error(err); }
|
||||||
console.log('pong');
|
|
||||||
clearTimeout(to);
|
clearTimeout(to);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
ping();
|
ping();
|
||||||
});
|
});
|
||||||
}, PING_INTERVAL);
|
}, PING_INTERVAL);
|
||||||
*/
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user