mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
socket.io: Reconnect if the server disconnects
This will make the pages gracefully handle HTTP server restart events, which happen whenever a plugin is installed or uninstalled via the `/admin/plugins` page.
This commit is contained in:
parent
303964c51e
commit
9f7d42185d
4 changed files with 36 additions and 8 deletions
|
@ -238,15 +238,25 @@ const handshake = () => {
|
|||
sendClientReady(receivedClientVars);
|
||||
});
|
||||
|
||||
socket.on('reconnecting', () => {
|
||||
const socketReconnecting = () => {
|
||||
// pad.collabClient might be null if the hanshake failed (or it never got that far).
|
||||
if (pad.collabClient != null) {
|
||||
pad.collabClient.setStateIdle();
|
||||
pad.collabClient.setIsPendingRevision(true);
|
||||
pad.collabClient.setChannelState('RECONNECTING');
|
||||
}
|
||||
};
|
||||
|
||||
socket.on('disconnect', (reason) => {
|
||||
// The socket.io client will automatically try to reconnect for all reasons other than "io
|
||||
// server disconnect".
|
||||
if (reason !== 'io server disconnect') return;
|
||||
socketReconnecting();
|
||||
socket.connect();
|
||||
});
|
||||
|
||||
socket.on('reconnecting', socketReconnecting);
|
||||
|
||||
socket.on('reconnect_failed', (error) => {
|
||||
// pad.collabClient might be null if the hanshake failed (or it never got that far).
|
||||
if (pad.collabClient != null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue