1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-29 11:05:44 +00:00
Lidarr/NzbDrone/Owin/MiddleWare/SignalRMiddleWare.cs

32 lines
1 KiB
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)
{
var url = string.Format("signalr/{0}", nzbDronePersistentConnection.Resource.Trim('/'));
appBuilder.MapConnection(url, nzbDronePersistentConnection.GetType(), new ConnectionConfiguration { EnableCrossDomain = true });
2013-05-05 21:24:33 +00:00
}
}
}
}