Force reconnect on server shutdown

This commit is contained in:
Pavel Djundik 2017-09-10 18:28:28 +03:00
parent 532f55cb86
commit 935c5b309a

View File

@ -2,6 +2,7 @@
const $ = require("jquery");
const io = require("socket.io-client");
const utils = require("./utils");
const path = window.location.pathname + "socket.io/";
const status = $("#loading-page-message, #connection-error");
@ -43,6 +44,12 @@ function handleDisconnect(data) {
status.text(`Waiting to reconnect… (${message})`).addClass("shown");
$(".show-more-button, #input").prop("disabled", true);
$("#submit").hide();
// If the server shuts down, socket.io skips reconnection
// and we have to manually call connect to start the process
if (socket.io.skipReconnect) {
utils.requestIdleCallback(() => socket.connect(), 2000);
}
}
module.exports = socket;