#172 attempt reconnect if signalR disconnects
This commit is contained in:
@@ -147,25 +147,10 @@
|
||||
hub.client.attachmentRemoved = document.DiscoFunctions.onAttachmentRemoved;
|
||||
|
||||
$.connection.hub.qs = { DeviceSerialNumber: deviceSerialNumber };
|
||||
$.connection.hub.error(onHubFailed);
|
||||
$.connection.hub.disconnected(onHubFailed);
|
||||
|
||||
$.connection.hub.reconnecting(function () {
|
||||
$('#AttachmentsContainer').find('span.action.enabled').addClass('disabled');
|
||||
$('#Comments').find('button').prop('disabled', true);
|
||||
$.connection.hub.error(function (error) {
|
||||
console.log('Server connection error: ' + error);
|
||||
});
|
||||
$.connection.hub.reconnected(function () {
|
||||
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
|
||||
$('#Comments').find('button').prop('disabled', false);
|
||||
});
|
||||
|
||||
// Start Connection
|
||||
$.connection.hub.start(function () {
|
||||
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
|
||||
$('#Comments').find('button').prop('disabled', false);
|
||||
}).fail(onHubFailed);
|
||||
|
||||
function onHubFailed(error) {
|
||||
$.connection.hub.disconnected(function () {
|
||||
// Disable UI
|
||||
$('#AttachmentsContainer').find('span.action.enabled').addClass('disabled');
|
||||
$('#Comments').find('button').prop('disabled', true);
|
||||
@@ -191,7 +176,22 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.connection.hub.reconnecting(function () {
|
||||
$('#AttachmentsContainer').find('span.action.enabled').addClass('disabled');
|
||||
$('#Comments').find('button').prop('disabled', true);
|
||||
});
|
||||
$.connection.hub.reconnected(function () {
|
||||
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
|
||||
$('#Comments').find('button').prop('disabled', false);
|
||||
});
|
||||
|
||||
// Start Connection
|
||||
$.connection.hub.start(function () {
|
||||
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
|
||||
$('#Comments').find('button').prop('disabled', false);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
@@ -514,39 +514,40 @@ WriteLiteral(" <script>\r\n $(function () {\r\n
|
||||
"d;\r\n if (document.DiscoFunctions.onAttachmentRemoved)\r\n " +
|
||||
" hub.client.attachmentRemoved = document.DiscoFunctions.onAttachmentRem" +
|
||||
"oved;\r\n\r\n $.connection.hub.qs = { DeviceSerialNumber: deviceSeria" +
|
||||
"lNumber };\r\n $.connection.hub.error(onHubFailed);\r\n " +
|
||||
" $.connection.hub.disconnected(onHubFailed);\r\n\r\n $.connection.hu" +
|
||||
"b.reconnecting(function () {\r\n $(\'#AttachmentsContainer\').fin" +
|
||||
"d(\'span.action.enabled\').addClass(\'disabled\');\r\n $(\'#Comments" +
|
||||
"\').find(\'button\').prop(\'disabled\', true);\r\n });\r\n " +
|
||||
"$.connection.hub.reconnected(function () {\r\n $(\'#AttachmentsC" +
|
||||
"ontainer\').find(\'span.action.enabled\').removeClass(\'disabled\');\r\n " +
|
||||
" $(\'#Comments\').find(\'button\').prop(\'disabled\', false);\r\n });" +
|
||||
"\r\n\r\n // Start Connection\r\n $.connection.hub.start(" +
|
||||
"function () {\r\n $(\'#AttachmentsContainer\').find(\'span.action." +
|
||||
"enabled\').removeClass(\'disabled\');\r\n $(\'#Comments\').find(\'but" +
|
||||
"ton\').prop(\'disabled\', false);\r\n }).fail(onHubFailed);\r\n\r\n " +
|
||||
" function onHubFailed(error) {\r\n // Disable UI\r\n " +
|
||||
" $(\'#AttachmentsContainer\').find(\'span.action.enabled\').addClass(\'" +
|
||||
"disabled\');\r\n $(\'#Comments\').find(\'button\').prop(\'disabled\', " +
|
||||
"true);\r\n\r\n // Show Dialog Message\r\n if ($(" +
|
||||
"\'.disconnected-dialog\').length == 0) {\r\n $(\'<div>\')\r\n " +
|
||||
" .addClass(\'dialog disconnected-dialog\')\r\n " +
|
||||
" .html(\'<h3><span class=\"fa-stack fa-lg\"><i class=\"fa fa-wifi fa-sta" +
|
||||
"ck-1x\"></i><i class=\"fa fa-ban fa-stack-2x error\"></i></span>Disconnected from t" +
|
||||
"he Disco ICT Server</h3><div>This page is not receiving live updates. Please ens" +
|
||||
"ure you are connected to the server, then refresh this page to enable features.<" +
|
||||
"/div>\')\r\n .dialog({\r\n " +
|
||||
"resizable: false,\r\n title: \'Disconnected\',\r\n " +
|
||||
" width: 400,\r\n modal: t" +
|
||||
"rue,\r\n buttons: {\r\n " +
|
||||
" \'Refresh Now\': function () {\r\n $(th" +
|
||||
"is).dialog(\'option\', \'buttons\', null);\r\n " +
|
||||
"window.location.reload(true);\r\n },\r\n " +
|
||||
" \'Close\': function () {\r\n " +
|
||||
" $(this).dialog(\'destroy\');\r\n }\r\n " +
|
||||
" }\r\n });\r\n " +
|
||||
" }\r\n }\r\n });\r\n </script>\r\n");
|
||||
"lNumber };\r\n $.connection.hub.error(function (error) {\r\n " +
|
||||
" console.log(\'Server connection error: \' + error);\r\n })" +
|
||||
";\r\n $.connection.hub.disconnected(function () {\r\n " +
|
||||
" // Disable UI\r\n $(\'#AttachmentsContainer\').find(\'span.act" +
|
||||
"ion.enabled\').addClass(\'disabled\');\r\n $(\'#Comments\').find(\'bu" +
|
||||
"tton\').prop(\'disabled\', true);\r\n\r\n // Show Dialog Message\r\n " +
|
||||
" if ($(\'.disconnected-dialog\').length == 0) {\r\n " +
|
||||
" $(\'<div>\')\r\n .addClass(\'dialog disconnected-d" +
|
||||
"ialog\')\r\n .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 p" +
|
||||
"age to enable features.</div>\')\r\n .dialog({\r\n " +
|
||||
" resizable: false,\r\n title" +
|
||||
": \'Disconnected\',\r\n width: 400,\r\n " +
|
||||
" modal: true,\r\n buttons: {\r\n " +
|
||||
" \'Refresh Now\': function () {\r\n " +
|
||||
" $(this).dialog(\'option\', \'buttons\', null);\r\n " +
|
||||
" window.location.reload(true);\r\n " +
|
||||
" },\r\n \'Close\': function () {\r\n " +
|
||||
" $(this).dialog(\'destroy\');\r\n " +
|
||||
" }\r\n }\r\n " +
|
||||
" });\r\n }\r\n });\r\n\r\n $.connec" +
|
||||
"tion.hub.reconnecting(function () {\r\n $(\'#AttachmentsContaine" +
|
||||
"r\').find(\'span.action.enabled\').addClass(\'disabled\');\r\n $(\'#C" +
|
||||
"omments\').find(\'button\').prop(\'disabled\', true);\r\n });\r\n " +
|
||||
" $.connection.hub.reconnected(function () {\r\n $(\'#Attac" +
|
||||
"hmentsContainer\').find(\'span.action.enabled\').removeClass(\'disabled\');\r\n " +
|
||||
" $(\'#Comments\').find(\'button\').prop(\'disabled\', false);\r\n " +
|
||||
" });\r\n\r\n // Start Connection\r\n $.connection.hub" +
|
||||
".start(function () {\r\n $(\'#AttachmentsContainer\').find(\'span." +
|
||||
"action.enabled\').removeClass(\'disabled\');\r\n $(\'#Comments\').fi" +
|
||||
"nd(\'button\').prop(\'disabled\', false);\r\n });\r\n });\r\n " +
|
||||
" </script>\r\n");
|
||||
|
||||
|
||||
#line 197 "..\..\Views\Device\Show.cshtml"
|
||||
|
||||
Reference in New Issue
Block a user