using System;
using Microsoft.AspNet.SignalR;
using NzbDrone.Common.Composition;
using NzbDrone.SignalR;
using Owin;

namespace NzbDrone.Host.Owin.MiddleWare
{
    public class SignalRMiddleWare : IOwinMiddleWare
    {
        public int Order { get { return 0; } }

        public SignalRMiddleWare(IContainer container)
        {
            SignalrDependencyResolver.Register(container);

            GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(300000);
        }

        public void Attach(IAppBuilder appBuilder)
        {
            appBuilder.MapConnection("signalr", typeof(NzbDronePersistentConnection), new ConnectionConfiguration { EnableCrossDomain = true });
        }
    }
}