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/HttpListenerHost.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 1cec4461b..16ca8b099 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -14,6 +14,7 @@ using ServiceStack.Host.HttpListener; using ServiceStack.Logging; using ServiceStack.Web; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; @@ -39,13 +40,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer public event EventHandler WebSocketConnected; + private readonly ConcurrentDictionary _localEndPoints = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + /// /// Gets the local end points. /// /// The local end points. public IEnumerable LocalEndPoints { - get { return _listener == null ? new List() : _listener.LocalEndPoints; } + get { return _listener == null ? new List() : _localEndPoints.Keys.ToList(); } } public HttpListenerHost(IApplicationHost applicationHost, ILogManager logManager, string serviceName, string handlerPath, string defaultRedirectPath, params Assembly[] assembliesWithServices) @@ -151,6 +154,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer return this; } + private void OnRequestReceived(string localEndPoint) + { + _localEndPoints.GetOrAdd(localEndPoint, localEndPoint); + } + /// /// Starts the Web Service /// @@ -159,9 +167,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer HostContext.Config.HandlerFactoryPath = ListenerRequest.GetHandlerPathIfAny(UrlPrefixes.First()); _listener = NativeWebSocket.IsSupported - ? _listener = new HttpListenerServer(_logger) + ? _listener = new HttpListenerServer(_logger, OnRequestReceived) //? _listener = new WebSocketSharpListener(_logger) - : _listener = new WebSocketSharpListener(_logger); + : _listener = new WebSocketSharpListener(_logger, OnRequestReceived); _listener.WebSocketHandler = WebSocketHandler; _listener.ErrorHandler = ErrorHandler; -- cgit v1.2.3