From 45db7d21b2a0a18b73253c64651a57c60880b084 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 31 Aug 2014 15:15:33 -0400 Subject: localize plugin installation process --- .../HttpServer/NetListener/HttpListenerServer.cs | 23 +++++++--------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs') diff --git a/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs b/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs index bdc2750fb..118bec60e 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs @@ -4,7 +4,6 @@ using ServiceStack; using ServiceStack.Host.HttpListener; using ServiceStack.Web; using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Net; @@ -20,26 +19,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer.NetListener private HttpListener _listener; private readonly AutoResetEvent _listenForNextRequest = new AutoResetEvent(false); - public System.Action ErrorHandler { get; set; } + public Action ErrorHandler { get; set; } public Action WebSocketHandler { get; set; } - public System.Func RequestHandler { get; set; } + public Func RequestHandler { get; set; } - private readonly ConcurrentDictionary _localEndPoints = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + private readonly Action _endpointListener; - public HttpListenerServer(ILogger logger) + public HttpListenerServer(ILogger logger, Action endpointListener) { _logger = logger; + _endpointListener = endpointListener; } - /// - /// Gets the local end points. - /// - /// The local end points. - public IEnumerable LocalEndPoints - { - get { return _localEndPoints.Keys.ToList(); } - } - private List UrlPrefixes { get; set; } public void Start(IEnumerable urlPrefixes) @@ -47,7 +38,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.NetListener UrlPrefixes = urlPrefixes.ToList(); if (_listener == null) - _listener = new System.Net.HttpListener(); + _listener = new HttpListener(); //HostContext.Config.HandlerFactoryPath = ListenerRequest.GetHandlerPathIfAny(UrlPrefixes.First()); @@ -229,7 +220,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.NetListener { var address = endpoint.ToString(); - _localEndPoints.GetOrAdd(address, address); + _endpointListener(address); } LogRequest(_logger, request); -- cgit v1.2.3