Fixed SignalR - Its FM!

This commit is contained in:
Mark McDowall 2012-12-18 17:40:47 -08:00
parent b73f7a02d7
commit eb42272764
6 changed files with 26 additions and 7 deletions

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NLog; using NLog;
using Ninject;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
@ -19,6 +20,7 @@ namespace NzbDrone.Core.Jobs
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public BacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob, public BacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob,
SeasonSearchJob seasonSearchJob, ConfigProvider configProvider) SeasonSearchJob seasonSearchJob, ConfigProvider configProvider)
{ {

View File

@ -310,6 +310,7 @@
<Compile Include="Providers\DecisionEngine\AllowedReleaseGroupSpecification.cs" /> <Compile Include="Providers\DecisionEngine\AllowedReleaseGroupSpecification.cs" />
<Compile Include="Providers\DecisionEngine\CustomStartDateSpecification.cs" /> <Compile Include="Providers\DecisionEngine\CustomStartDateSpecification.cs" />
<Compile Include="Providers\DownloadClients\PneumaticProvider.cs" /> <Compile Include="Providers\DownloadClients\PneumaticProvider.cs" />
<Compile Include="Providers\Hubs\EpisodeHub.cs" />
<Compile Include="Providers\Indexer\NzbClub.cs" /> <Compile Include="Providers\Indexer\NzbClub.cs" />
<Compile Include="Providers\Indexer\NzbIndex.cs" /> <Compile Include="Providers\Indexer\NzbIndex.cs" />
<Compile Include="Providers\Indexer\FileSharingTalk.cs" /> <Compile Include="Providers\Indexer\FileSharingTalk.cs" />

View File

@ -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
{
}
}

View File

@ -3,16 +3,15 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using NLog; using NLog;
using Ninject;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Providers.Hubs;
using SignalR; using SignalR;
using SignalR.Hosting.AspNet;
using SignalR.Hubs; using SignalR.Hubs;
using SignalR.Infrastructure;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class SignalRProvider : Hub public class SignalRProvider
{ {
private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private static readonly Logger logger = LogManager.GetCurrentClassLogger();
@ -22,7 +21,8 @@ namespace NzbDrone.Core.Providers
{ {
logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus); logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus);
Clients.updatedStatus(new var context = GlobalHost.ConnectionManager.GetHubContext<EpisodeHub>();
context.Clients.updatedStatus(new
{ {
EpisodeId = episodeId, EpisodeId = episodeId,
EpisodeStatus = episodeStatus.ToString(), EpisodeStatus = episodeStatus.ToString(),

View File

@ -19,6 +19,7 @@ using ServiceStack.CacheAccess.Providers;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Helpers.Binders; using NzbDrone.Web.Helpers.Binders;
using ServiceStack.ServiceInterface; using ServiceStack.ServiceInterface;
using SignalR;
namespace NzbDrone.Web namespace NzbDrone.Web
{ {
@ -71,6 +72,9 @@ namespace NzbDrone.Web
dispatch.Kernel.Load(Assembly.GetExecutingAssembly()); dispatch.Kernel.Load(Assembly.GetExecutingAssembly());
//SignalR
RouteTable.Routes.MapHubs();
//ServiceStack //ServiceStack
dispatch.Kernel.Bind<ICacheClient>().To<MemoryCacheClient>().InSingletonScope(); dispatch.Kernel.Bind<ICacheClient>().To<MemoryCacheClient>().InSingletonScope();
dispatch.Kernel.Bind<ISessionFactory>().To<SessionFactory>().InSingletonScope(); dispatch.Kernel.Bind<ISessionFactory>().To<SessionFactory>().InSingletonScope();

View File

@ -66,10 +66,10 @@ function reloadGrid() {
//SignalR //SignalR
$(function () { $(function () {
// Proxy created on the fly // 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 // 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 + '"]'); var row = $('[data-episode-id="' + data.EpisodeId + '"]');
if (row.length == 0) if (row.length == 0)