[feature] Create option to automatically reconnect after a few seconds

On some erros that display a modal with "Force reconnect" button, allow
Etherpad to automatically reload pad after a few seconds. Amount of
seconds is defined on settings.json.

Still need to create tests for this feature, and implement i18n.
This commit is contained in:
Luiza Pagliari 2017-04-04 11:09:24 -03:00
parent ed029b599e
commit 009cd31243
7 changed files with 180 additions and 14 deletions

View file

@ -936,7 +936,7 @@ function handleSwitchToPad(client, message)
var currentSession = sessioninfos[client.id];
var padId = currentSession.padId;
var roomClients = _getRoomClients(padId);
async.forEach(roomClients, function(client, callback) {
var sinfo = sessioninfos[client.id];
if(sinfo && sinfo.author == currentSession.author) {
@ -1115,7 +1115,7 @@ function handleClientReady(client, message)
//Check if this author is already on the pad, if yes, kick the other sessions!
var roomClients = _getRoomClients(pad.id);
async.forEach(roomClients, function(client, callback) {
var sinfo = sessioninfos[client.id];
if(sinfo && sinfo.author == author) {
@ -1176,6 +1176,7 @@ function handleClientReady(client, message)
"accountPrivs": {
"maxRevisions": 100
},
"automaticReconnectionTimeout": settings.automaticReconnectionTimeout,
"initialRevisionList": [],
"initialOptions": {
"guestPolicy": "deny"
@ -1676,13 +1677,13 @@ function composePadChangesets(padId, startNum, endNum, callback)
function _getRoomClients(padID) {
var roomClients = []; var room = socketio.sockets.adapter.rooms[padID];
if (room) {
for (var id in room.sockets) {
roomClients.push(socketio.sockets.sockets[id]);
}
}
return roomClients;
}

View file

@ -177,6 +177,11 @@ exports.loglevel = "INFO";
*/
exports.disableIPlogging = false;
/**
* Number of seconds to automatically reconnect pad
*/
exports.automaticReconnectionTimeout = 0;
/**
* Disable Load Testing
*/