1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone/Owin/MiddleWare/SignalRMiddleWare.cs

32 lines
1.0 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2013-05-06 00:24:33 +03:00
using Microsoft.AspNet.SignalR;
using NzbDrone.Api.SignalR;
using Owin;
2013-05-06 00:24:33 +03:00
using TinyIoC;
namespace NzbDrone.Owin.MiddleWare
{
public class SignalRMiddleWare : IOwinMiddleWare
{
2013-05-06 00:24:33 +03:00
private readonly IEnumerable<NzbDronePersistentConnection> _persistentConnections;
2013-05-06 00:24:33 +03:00
public int Order { get { return 0; } }
public SignalRMiddleWare(IEnumerable<NzbDronePersistentConnection> persistentConnections, TinyIoCContainer container)
{
2013-05-06 00:24:33 +03:00
_persistentConnections = persistentConnections;
SignalrDependencyResolver.Register(container);
}
public void Attach(IAppBuilder appBuilder)
{
2013-05-06 00:24:33 +03: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-06 00:24:33 +03:00
}
}
}
}