1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-10 13:02:47 +01:00

Messaging to handle signalR disconnection and reconnection added

This commit is contained in:
Mark McDowall 2013-11-11 23:43:26 -08:00
parent 1a33896e05
commit 53a7ed94e1
3 changed files with 52 additions and 4 deletions

View File

@ -14,7 +14,7 @@ public SignalRMiddleWare(IContainer container)
{ {
SignalrDependencyResolver.Register(container); SignalrDependencyResolver.Register(container);
GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(300000); GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromMinutes(3);
} }
public void Attach(IAppBuilder appBuilder) public void Attach(IAppBuilder appBuilder)

View File

@ -28,7 +28,8 @@ define(function () {
type : options.type, type : options.type,
showCloseButton: true, showCloseButton: true,
hideAfter : options.hideAfter, hideAfter : options.hideAfter,
id : options.id id : options.id,
actions : options.actions
}); });
}, },

View File

@ -3,8 +3,9 @@ define(
[ [
'vent', 'vent',
'jquery', 'jquery',
'Shared/Messenger',
'signalR' 'signalR'
], function (vent, $) { ], function (vent, $, Messenger) {
return { return {
appInitializer: function () { appInitializer: function () {
@ -25,6 +26,9 @@ define(
} }
}; };
var tryingToReconnect = false;
var messengerId = 'signalR';
this.signalRconnection = $.connection('/signalr'); this.signalRconnection = $.connection('/signalr');
this.signalRconnection.stateChanged(function (change) { this.signalRconnection.stateChanged(function (change) {
@ -35,6 +39,49 @@ define(
vent.trigger('server:' + message.name, message.body); vent.trigger('server:' + message.name, message.body);
}); });
this.signalRconnection.reconnecting(function() {
tryingToReconnect = true;
Messenger.show({
id : messengerId,
type : 'info',
hideAfter : 0,
message : 'Connection to backend lost, attempting to reconnect'
});
});
this.signalRconnection.reconnected(function() {
tryingToReconnect = false;
Messenger.show({
id : messengerId,
type : 'success',
hideAfter : 5,
message : 'Connection to backend restored'
});
});
this.signalRconnection.disconnected(function () {
if (tryingToReconnect) {
$('<div class="modal-backdrop"></div>').appendTo(document.body);
Messenger.show({
id : messengerId,
type : 'error',
hideAfter : 0,
message : 'Connection to backend lost',
actions : {
cancel: {
label: 'Reload',
action: function() {
window.location.reload();
}
}
}
});
}
});
this.signalRconnection.start({ transport: this.signalRconnection.start({ transport:
[ [
'longPolling' 'longPolling'