Ability to reconnect after a connection failure

pull/1/head
yflory 8 years ago
parent 5a3da11c40
commit c168ce2d1c

@ -224,10 +224,11 @@ define([
return {
failed: function () {
connected = false;
userListElement.textContent = '';
userListElement.textContent = 'Disconnected';
lagElement.textContent = '';
},
reconnecting: function () {
reconnecting: function (userId) {
myUserName = userId;
connected = false;
userListElement.textContent = Messages.reconnecting;
lagElement.textContent = '';

@ -603,6 +603,18 @@ define([
Cryptpad.alert(Messages.disconnectAlert);
};
var onConnectionChange = realtimeOptions.onConnectionChange = function (info) {
setEditable(info.state);
toolbar.failed();
if (info.state) {
initializing = true;
toolbar.reconnecting(info.myId);
Cryptpad.findOKButton().click();
} else {
Cryptpad.alert(Messages.disconnectAlert);
}
};
var onLocal = realtimeOptions.onLocal = function () {
if (initializing) { return; }

@ -74,10 +74,19 @@ define([
};
var onAbort = config.onAbort = function (info) {
$textarea.attr('disabled', true);
setEditable(false);
window.alert("Server Connection Lost");
};
var onConnectionChange = config.onConnectionChange = function (info) {
if (info.state) {
initializing = true;
} else {
setEditable(false);
window.alert("Server Connection Lost. Trying to reconnect...");
}
};
var rt = Realtime.start(config);
['cut', 'paste', 'change', 'keyup', 'keydown', 'select', 'textInput']

Loading…
Cancel
Save