#172 attempt reconnect if signalR disconnects

This commit is contained in:
Gary Sharp
2025-07-17 12:44:06 +10:00
parent f8fd1a58a3
commit 0905a02aea
20 changed files with 539 additions and 524 deletions
@@ -147,7 +147,6 @@
if (self.FullUpdateToken)
window.clearTimeout(self.FullUpdateToken);
$.connection.hub.stop();
if (self.FinishedMessage())
window.setTimeout(function () { window.location.href = self.FinishedUrl(); }, 3000);
@@ -247,35 +246,36 @@
notificationsHub.client.updateTaskStatus = vm.Update;
$.connection.hub.qs = { TaskSessionId: sessionId };
$.connection.hub.error(onHubFailed);
$.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
});
$.connection.hub.disconnected(function () {
// Show Dialog Message
if ($('.disconnected-dialog').length == 0) {
$('<div>')
.addClass('dialog disconnected-dialog')
.html('<h3><span class="fa-stack fa-lg"><i class="fa fa-wifi fa-stack-1x"></i><i class="fa fa-ban fa-stack-2x error"></i></span>Disconnected from the Disco ICT Server</h3><div>This page is not receiving live updates. Please ensure you are connected to the server, then refresh this page to enable features.</div>')
.dialog({
resizable: false,
title: 'Disconnected',
width: 400,
modal: true,
buttons: {
'Refresh Now': function () {
$(this).dialog('option', 'buttons', null);
window.location.reload(true);
},
'Close': function () {
$(this).dialog('destroy');
}
}
});
}
})
$.connection.hub.start()
.fail(onHubFailed);
}
function onHubFailed(error) {
// Show Dialog Message
if ($('.disconnected-dialog').length == 0) {
$('<div>')
.addClass('dialog disconnected-dialog')
.html('<h3><span class="fa-stack fa-lg"><i class="fa fa-wifi fa-stack-1x"></i><i class="fa fa-ban fa-stack-2x error"></i></span>Disconnected from the Disco ICT Server</h3><div>This page is not receiving live updates. Please ensure you are connected to the server, then refresh this page to enable features.</div>')
.dialog({
resizable: false,
title: 'Disconnected',
width: 400,
modal: true,
buttons: {
'Refresh Now': function () {
$(this).dialog('option', 'buttons', null);
window.location.reload(true);
},
'Close': function () {
$(this).dialog('destroy');
}
}
});
}
}
});
</script>