Radarr/NzbDrone.Core/Providers/SignalRProvider.cs

46 lines
1.5 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using SignalR;
using SignalR.Hosting.AspNet;
using SignalR.Hubs;
using SignalR.Infrastructure;
namespace NzbDrone.Core.Providers
{
public class SignalRProvider : Hub
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
2012-10-13 21:15:21 +00:00
public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episodeStatus, QualityModel quality)
{
try
{
logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus);
GetClients().updatedStatus(new
{
EpisodeId = episodeId,
EpisodeStatus = episodeStatus.ToString(),
2012-10-14 00:36:16 +00:00
Quality = (quality == null ? String.Empty : quality.Quality.ToString())
});
}
catch (Exception ex)
{
2012-11-21 16:14:57 +00:00
logger.TraceException("Error", ex);
throw;
}
}
private dynamic GetClients()
{
var connectionManager = AspNetHost.DependencyResolver.Resolve<IConnectionManager>();
return connectionManager.GetClients<SignalRProvider>();
}
}
}