From eb422727649151fbe559c3ff8300d24cc786076a Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 18 Dec 2012 17:40:47 -0800 Subject: [PATCH] Fixed SignalR - Its FM! --- NzbDrone.Core/Jobs/BacklogSearchJob.cs | 2 ++ NzbDrone.Core/NzbDrone.Core.csproj | 1 + NzbDrone.Core/Providers/Hubs/EpisodeHub.cs | 12 ++++++++++++ NzbDrone.Core/Providers/SignalRProvider.cs | 10 +++++----- NzbDrone.Web/Global.asax.cs | 4 ++++ NzbDrone.Web/Scripts/NzbDrone/grid.js | 4 ++-- 6 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 NzbDrone.Core/Providers/Hubs/EpisodeHub.cs diff --git a/NzbDrone.Core/Jobs/BacklogSearchJob.cs b/NzbDrone.Core/Jobs/BacklogSearchJob.cs index df682f99d..3699b4c3c 100644 --- a/NzbDrone.Core/Jobs/BacklogSearchJob.cs +++ b/NzbDrone.Core/Jobs/BacklogSearchJob.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using NLog; +using Ninject; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -19,6 +20,7 @@ public class BacklogSearchJob : IJob private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + [Inject] public BacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob, SeasonSearchJob seasonSearchJob, ConfigProvider configProvider) { diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index c920e1c2f..29ac80896 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -310,6 +310,7 @@ + diff --git a/NzbDrone.Core/Providers/Hubs/EpisodeHub.cs b/NzbDrone.Core/Providers/Hubs/EpisodeHub.cs new file mode 100644 index 000000000..7777d53c5 --- /dev/null +++ b/NzbDrone.Core/Providers/Hubs/EpisodeHub.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using SignalR.Hubs; + +namespace NzbDrone.Core.Providers.Hubs +{ + public class EpisodeHub : Hub + { + } +} diff --git a/NzbDrone.Core/Providers/SignalRProvider.cs b/NzbDrone.Core/Providers/SignalRProvider.cs index b85cacc7f..e4c5b8626 100644 --- a/NzbDrone.Core/Providers/SignalRProvider.cs +++ b/NzbDrone.Core/Providers/SignalRProvider.cs @@ -3,16 +3,15 @@ using System.Linq; using System.Text; using NLog; +using Ninject; using NzbDrone.Core.Model; -using NzbDrone.Core.Repository.Quality; +using NzbDrone.Core.Providers.Hubs; using SignalR; -using SignalR.Hosting.AspNet; using SignalR.Hubs; -using SignalR.Infrastructure; namespace NzbDrone.Core.Providers { - public class SignalRProvider : Hub + public class SignalRProvider { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); @@ -22,7 +21,8 @@ public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episode { logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus); - Clients.updatedStatus(new + var context = GlobalHost.ConnectionManager.GetHubContext(); + context.Clients.updatedStatus(new { EpisodeId = episodeId, EpisodeStatus = episodeStatus.ToString(), diff --git a/NzbDrone.Web/Global.asax.cs b/NzbDrone.Web/Global.asax.cs index fbb12f82c..4cd145331 100644 --- a/NzbDrone.Web/Global.asax.cs +++ b/NzbDrone.Web/Global.asax.cs @@ -19,6 +19,7 @@ using NzbDrone.Core.Repository.Quality; using NzbDrone.Web.Helpers.Binders; using ServiceStack.ServiceInterface; +using SignalR; namespace NzbDrone.Web { @@ -71,6 +72,9 @@ protected override IKernel CreateKernel() dispatch.Kernel.Load(Assembly.GetExecutingAssembly()); + //SignalR + RouteTable.Routes.MapHubs(); + //ServiceStack dispatch.Kernel.Bind().To().InSingletonScope(); dispatch.Kernel.Bind().To().InSingletonScope(); diff --git a/NzbDrone.Web/Scripts/NzbDrone/grid.js b/NzbDrone.Web/Scripts/NzbDrone/grid.js index e2611f486..c6d9fa170 100644 --- a/NzbDrone.Web/Scripts/NzbDrone/grid.js +++ b/NzbDrone.Web/Scripts/NzbDrone/grid.js @@ -66,10 +66,10 @@ function reloadGrid() { //SignalR $(function () { // Proxy created on the fly - var signalRProvider = $.connection.signalRProvider; + var episodeHub = $.connection.episodeHub; // Declare a function on the chat hub so the server can invoke it - signalRProvider.updatedStatus = function (data) { + episodeHub.updatedStatus = function (data) { var row = $('[data-episode-id="' + data.EpisodeId + '"]'); if (row.length == 0)