Detect phantom tabs using PING in the worker
This commit is contained in:
@@ -1058,14 +1058,12 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var timeout = false;
|
var timeout = false;
|
||||||
|
common.onTimeoutEvent = Util.mkEvent();
|
||||||
var onTimeout = function () {
|
var onTimeout = function () {
|
||||||
return;
|
|
||||||
/*
|
|
||||||
timeout = true;
|
timeout = true;
|
||||||
common.onNetworkDisconnect.fire();
|
common.onNetworkDisconnect.fire();
|
||||||
// FIXME: no UI in outer...
|
common.padRpc.onDisconnectEvent.fire();
|
||||||
window.alert("Timeout error, please reload this tab");
|
common.onTimeoutEvent.fire();
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var queries = {
|
var queries = {
|
||||||
|
|||||||
@@ -1602,12 +1602,11 @@ 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;
|
||||||
var MAX_PING = 1000;
|
var MAX_PING = 5000;
|
||||||
var MAX_FAILED_PING = 5;
|
var MAX_FAILED_PING = 2;
|
||||||
|
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
var clients = [];
|
var clients = [];
|
||||||
@@ -1635,7 +1634,6 @@ define([
|
|||||||
ping();
|
ping();
|
||||||
});
|
});
|
||||||
}, PING_INTERVAL);
|
}, PING_INTERVAL);
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -874,6 +874,10 @@ define([
|
|||||||
Cryptpad.cursor.execCommand(data, cb);
|
Cryptpad.cursor.execCommand(data, cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Cryptpad.onTimeoutEvent.reg(function () {
|
||||||
|
sframeChan.event('EV_WORKER_TIMEOUT');
|
||||||
|
});
|
||||||
|
|
||||||
if (cfg.messaging) {
|
if (cfg.messaging) {
|
||||||
Notifier.getPermission();
|
Notifier.getPermission();
|
||||||
|
|
||||||
|
|||||||
@@ -613,6 +613,10 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ctx.sframeChan.on('EV_WORKER_TIMEOUT', function () {
|
||||||
|
UI.errorLoadingScreen(Messages.timeoutError) // XXX
|
||||||
|
});
|
||||||
|
|
||||||
ctx.sframeChan.on('EV_CHROME_68', function () {
|
ctx.sframeChan.on('EV_CHROME_68', function () {
|
||||||
UI.alert(Messages.chrome68);
|
UI.alert(Messages.chrome68);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user