sonarr-repo-only/NzbDrone/Owin/MiddleWare/SignalRMiddleWare.cs

31 lines
971 B
C#
Raw Normal View History

using System.Collections.Generic;
2013-05-05 21:24:33 +00:00
using Microsoft.AspNet.SignalR;
using NzbDrone.Api.SignalR;
using Owin;
2013-05-05 21:24:33 +00:00
using TinyIoC;
namespace NzbDrone.Owin.MiddleWare
{
public class SignalRMiddleWare : IOwinMiddleWare
{
2013-05-05 21:24:33 +00:00
private readonly IEnumerable<NzbDronePersistentConnection> _persistentConnections;
2013-05-05 21:24:33 +00:00
public int Order { get { return 0; } }
public SignalRMiddleWare(IEnumerable<NzbDronePersistentConnection> persistentConnections, TinyIoCContainer container)
{
2013-05-05 21:24:33 +00:00
_persistentConnections = persistentConnections;
SignalrDependencyResolver.Register(container);
}
public void Attach(IAppBuilder appBuilder)
{
2013-05-05 21:24:33 +00:00
foreach (var nzbDronePersistentConnection in _persistentConnections)
{
appBuilder.MapConnection("signalr/series", nzbDronePersistentConnection.GetType(), new ConnectionConfiguration { EnableCrossDomain = true });
}
}
}
}