mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 00:53:57 -07:00
signalr cleanup
This commit is contained in:
parent
feda4a9b67
commit
25e2c98c45
219 changed files with 2035 additions and 1495 deletions
51
UI/Shared/SignalRBroadcaster.js
Normal file
51
UI/Shared/SignalRBroadcaster.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'signalR'
|
||||
], function () {
|
||||
return {
|
||||
|
||||
appInitializer: function () {
|
||||
console.log('starting signalR');
|
||||
|
||||
var getStatus = function (status) {
|
||||
switch (status) {
|
||||
case 0:
|
||||
return 'connecting';
|
||||
case 1:
|
||||
return 'connected';
|
||||
case 2:
|
||||
return 'reconnecting';
|
||||
case 4:
|
||||
return 'disconnected';
|
||||
default:
|
||||
throw 'invalid status ' + status;
|
||||
}
|
||||
};
|
||||
|
||||
this.signalRconnection = $.connection("/signalr");
|
||||
|
||||
this.signalRconnection.stateChanged(function (change) {
|
||||
console.debug('SignalR: [{0}]'.format(getStatus(change.newState)));
|
||||
});
|
||||
|
||||
this.signalRconnection.received(function (message) {
|
||||
require(
|
||||
[
|
||||
'app'
|
||||
], function (app) {
|
||||
app.vent.trigger('server:' + message.name, message.body);
|
||||
})
|
||||
});
|
||||
|
||||
this.signalRconnection.start({ transport:
|
||||
[
|
||||
'longPolling'
|
||||
] });
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue