diff --git a/MediaBrowser.Common/Net/IServerManager.cs b/MediaBrowser.Common/Net/IServerManager.cs
index 3234e70600..32be88a346 100644
--- a/MediaBrowser.Common/Net/IServerManager.cs
+++ b/MediaBrowser.Common/Net/IServerManager.cs
@@ -5,6 +5,9 @@ using System.Threading.Tasks;
namespace MediaBrowser.Common.Net
{
+ ///
+ /// Interface IServerManager
+ ///
public interface IServerManager : IDisposable
{
///
@@ -22,7 +25,14 @@ namespace MediaBrowser.Common.Net
///
/// Starts this instance.
///
- void Start();
+ /// The URL prefix.
+ /// if set to true [enable HTTP logging].
+ void Start(string urlPrefix, bool enableHttpLogging);
+
+ ///
+ /// Starts the web socket server.
+ ///
+ void StartWebSocketServer();
///
/// Sends a message to all clients currently connected via a web socket
@@ -62,7 +72,7 @@ namespace MediaBrowser.Common.Net
/// The cancellation token.
/// Task.
Task SendWebSocketMessageAsync(string messageType, Func dataFunction, IEnumerable connections, CancellationToken cancellationToken);
-
+
///
/// Adds the web socket listeners.
///
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
index aa30cee26f..7792a28bb0 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
@@ -529,7 +529,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{
new ClientWebSocket();
- _supportsNativeWebSocket = true;
+ _supportsNativeWebSocket = false;
}
catch (PlatformNotSupportedException)
{
diff --git a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs
index b63cf00317..a840ae214a 100644
--- a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs
+++ b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs
@@ -118,43 +118,44 @@ namespace MediaBrowser.Server.Implementations.ServerManager
_jsonSerializer = jsonSerializer;
_applicationHost = applicationHost;
ConfigurationManager = configurationManager;
-
- ConfigurationManager.ConfigurationUpdated += ConfigurationUpdated;
}
///
/// Starts this instance.
///
- public void Start()
+ public void Start(string urlPrefix, bool enableHttpLogging)
{
- ReloadHttpServer();
+ ReloadHttpServer(urlPrefix, enableHttpLogging);
+ }
+ public void StartWebSocketServer()
+ {
if (!SupportsNativeWebSocket)
{
- ReloadExternalWebSocketServer();
+ ReloadExternalWebSocketServer(ConfigurationManager.Configuration.LegacyWebSocketPortNumber);
}
}
///
/// Starts the external web socket server.
///
- private void ReloadExternalWebSocketServer()
+ private void ReloadExternalWebSocketServer(int portNumber)
{
DisposeExternalWebSocketServer();
ExternalWebSocketServer = _applicationHost.Resolve();
- ExternalWebSocketServer.Start(ConfigurationManager.Configuration.LegacyWebSocketPortNumber);
+ ExternalWebSocketServer.Start(portNumber);
ExternalWebSocketServer.WebSocketConnected += HttpServer_WebSocketConnected;
}
///
/// Restarts the Http Server, or starts it if not currently running
///
- private void ReloadHttpServer()
+ private void ReloadHttpServer(string urlPrefix, bool enableHttpLogging)
{
// Only reload if the port has changed, so that we don't disconnect any active users
- if (HttpServer != null && HttpServer.UrlPrefix.Equals(_applicationHost.HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
+ if (HttpServer != null && HttpServer.UrlPrefix.Equals(urlPrefix, StringComparison.OrdinalIgnoreCase))
{
return;
}
@@ -166,8 +167,8 @@ namespace MediaBrowser.Server.Implementations.ServerManager
try
{
HttpServer = _applicationHost.Resolve();
- HttpServer.EnableHttpRequestLogging = ConfigurationManager.Configuration.EnableHttpLevelLogging;
- HttpServer.Start(_applicationHost.HttpServerUrlPrefix);
+ HttpServer.EnableHttpRequestLogging = enableHttpLogging;
+ HttpServer.Start(urlPrefix);
}
catch (SocketException ex)
{
@@ -375,17 +376,6 @@ namespace MediaBrowser.Server.Implementations.ServerManager
}
}
- ///
- /// Handles the ConfigurationUpdated event of the _kernel control.
- ///
- /// The source of the event.
- /// The instance containing the event data.
- ///
- void ConfigurationUpdated(object sender, EventArgs e)
- {
- HttpServer.EnableHttpRequestLogging = ConfigurationManager.Configuration.EnableHttpLevelLogging;
- }
-
///
/// Adds the web socket listeners.
///
diff --git a/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs b/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs
index 6649fd1978..1470a209e6 100644
--- a/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs
+++ b/MediaBrowser.Server.Implementations/WebSocket/AlchemyServer.cs
@@ -55,14 +55,14 @@ namespace MediaBrowser.Server.Implementations.WebSocket
/// The port number.
public void Start(int portNumber)
{
- WebSocketServer = new WebSocketServer(portNumber, IPAddress.Any)
- {
- OnConnected = OnAlchemyWebSocketClientConnected,
- TimeOut = TimeSpan.FromHours(12)
- };
-
try
{
+ WebSocketServer = new WebSocketServer(portNumber, IPAddress.Any)
+ {
+ OnConnected = OnAlchemyWebSocketClientConnected,
+ TimeOut = TimeSpan.FromHours(12)
+ };
+
WebSocketServer.Start();
}
catch (SocketException ex)
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index 126bea9e5a..13afb41e72 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Api;
+using System.Windows.Forms;
+using MediaBrowser.Api;
using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Constants;
@@ -475,7 +476,7 @@ namespace MediaBrowser.ServerApplication
{
try
{
- ServerManager.Start();
+ ServerManager.Start(HttpServerUrlPrefix, ServerConfigurationManager.Configuration.EnableHttpLevelLogging);
}
catch
{
@@ -490,6 +491,8 @@ namespace MediaBrowser.ServerApplication
throw;
}
}
+
+ ServerManager.StartWebSocketServer();
}
///
@@ -501,6 +504,8 @@ namespace MediaBrowser.ServerApplication
{
base.OnConfigurationUpdated(sender, e);
+ HttpServer.EnableHttpRequestLogging = ServerConfigurationManager.Configuration.EnableHttpLevelLogging;
+
if (!string.Equals(HttpServer.UrlPrefix, HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
{
NotifyPendingRestart();