#172 attempt reconnect if signalR disconnects
This commit is contained in:
@@ -137,25 +137,10 @@
|
||||
hub.client.attachmentRemoved = document.DiscoFunctions.onAttachmentRemoved;
|
||||
|
||||
$.connection.hub.qs = { UserId: userId };
|
||||
$.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);
|
||||
@@ -181,7 +166,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>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user