1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-01 00:12:30 +01:00
Sonarr/NzbDrone/Owin/MiddleWare/SignalRMiddleWare.cs
2013-05-10 20:43:52 -07:00

32 lines
1.1 KiB
C#

using System.Collections.Generic;
using Microsoft.AspNet.SignalR;
using NzbDrone.Api.SignalR;
using NzbDrone.Common.Composition;
using Owin;
namespace NzbDrone.Owin.MiddleWare
{
public class SignalRMiddleWare : IOwinMiddleWare
{
private readonly IEnumerable<NzbDronePersistentConnection> _persistentConnections;
public int Order { get { return 0; } }
public SignalRMiddleWare(IEnumerable<NzbDronePersistentConnection> persistentConnections, IContainer container)
{
_persistentConnections = persistentConnections;
SignalrDependencyResolver.Register(container);
}
public void Attach(IAppBuilder appBuilder)
{
foreach (var nzbDronePersistentConnection in _persistentConnections)
{
var url = string.Format("signalr/{0}", nzbDronePersistentConnection.Resource.Trim('/'));
appBuilder.MapConnection(url, nzbDronePersistentConnection.GetType(), new ConnectionConfiguration { EnableCrossDomain = true });
}
}
}
}