signalr-episodes

This commit is contained in:
Mark McDowall 2013-09-30 08:09:47 -07:00
commit b6693a20a9
6 changed files with 44 additions and 12 deletions

View file

@ -1,8 +1,10 @@
'use strict';
define(
[
'underscore',
'backbone',
'signalR'
], function () {
], function (_, Backbone) {
_.extend(Backbone.Collection.prototype, {
bindSignalR: function () {
@ -13,14 +15,14 @@ define(
var model = new collection.model(options.resource, {parse: true});
collection.add(model, {merge: true});
console.log(options.action + ": %O", options.resource);
console.log(options.action + ': {0}}'.format(options.resource));
};
require(
[
'app'
], function (app) {
collection.listenTo(app.vent, 'server:' + collection.url.replace('/api/', ''), processMessage)
collection.listenTo(app.vent, 'server:' + collection.url.replace('/api/', ''), processMessage);
});
return this;
@ -28,7 +30,6 @@ define(
unbindSignalR: function () {
}});
});

View file

@ -171,7 +171,7 @@ define(
this.seasons.show(new LoadingView());
this.seasonCollection = new SeasonCollection(this.model.get('seasons'));
this.episodeCollection = new EpisodeCollection({ seriesId: this.model.id });
this.episodeCollection = new EpisodeCollection({ seriesId: this.model.id }).bindSignalR();
this.episodeFileCollection = new EpisodeFileCollection({ seriesId: this.model.id });
$.when(this.episodeCollection.fetch(), this.episodeFileCollection.fetch()).done(function () {

View file

@ -24,7 +24,7 @@ define(
}
};
this.signalRconnection = $.connection("/signalr");
this.signalRconnection = $.connection('/signalr');
this.signalRconnection.stateChanged(function (change) {
console.debug('SignalR: [{0}]'.format(getStatus(change.newState)));
@ -36,7 +36,7 @@ define(
'app'
], function (app) {
app.vent.trigger('server:' + message.name, message.body);
})
});
});
this.signalRconnection.start({ transport: