The Free Software Media System - Server Backend & API
get to the tray icon a little quicker
Luke Pulverenti407016a30702
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.csindex 34bdda94f1..7451b6b97f 100644--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs@@ -180,8 +180,6 @@ namespace MediaBrowser.Common.Implementationsawait RegisterResources().ConfigureAwait(false);FindParts();-- await RunStartupTasks().ConfigureAwait(false);}protected virtual void OnLoggerLoaded()@@ -193,7 +191,7 @@ namespace MediaBrowser.Common.Implementations/// Runs the startup tasks./// </summary>/// <returns>Task.</returns>- protected virtual Task RunStartupTasks()+ public virtual Task RunStartupTasks(){return Task.Run(() =>{diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.csindex 762eb4cd23..5a1d7505c4 100644--- a/MediaBrowser.ServerApplication/App.xaml.cs+++ b/MediaBrowser.ServerApplication/App.xaml.cs@@ -6,6 +6,7 @@ using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Entities;using MediaBrowser.Model.Logging;using MediaBrowser.Server.Implementations;+using MediaBrowser.ServerApplication.Splash;using Microsoft.Win32;using System;using System.Diagnostics;@@ -164,11 +165,19 @@ namespace MediaBrowser.ServerApplicationLogger = CompositionRoot.LogManager.GetLogger("App");+ var splash = new SplashWindow(CompositionRoot.ApplicationVersion);++ splash.Show();+await CompositionRoot.Init();- var win = new MainWindow(CompositionRoot.LogManager, CompositionRoot, CompositionRoot.ServerConfigurationManager, CompositionRoot.UserManager, CompositionRoot.LibraryManager, CompositionRoot.JsonSerializer, CompositionRoot.DisplayPreferencesManager);+ splash.Hide();++ var task = CompositionRoot.RunStartupTasks();++ new MainWindow(CompositionRoot.LogManager, CompositionRoot, CompositionRoot.ServerConfigurationManager, CompositionRoot.UserManager, CompositionRoot.LibraryManager, CompositionRoot.JsonSerializer, CompositionRoot.DisplayPreferencesManager).Show();- win.Show();+ await task.ConfigureAwait(false);}catch (Exception ex){diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.csindex 4dd24d98f2..35a9698c3e 100644--- a/MediaBrowser.ServerApplication/ApplicationHost.cs+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs@@ -44,7 +44,6 @@ using MediaBrowser.Server.Implementations.Udp;using MediaBrowser.Server.Implementations.Updates;using MediaBrowser.Server.Implementations.WebSocket;using MediaBrowser.ServerApplication.Implementations;-using MediaBrowser.ServerApplication.Splash;using MediaBrowser.WebDashboard.Api;using System;using System.Collections.Generic;@@ -63,7 +62,7 @@ namespace MediaBrowser.ServerApplication/// </summary>public class ApplicationHost : BaseApplicationHost<ServerApplicationPaths>, IServerApplicationHost{- private const int UdpServerPort = 7359;+ internal const int UdpServerPort = 7359;/// <summary>/// Gets the server kernel.@@ -139,11 +138,6 @@ namespace MediaBrowser.ServerApplication/// <value>The HTTP server.</value>private IHttpServer HttpServer { get; set; }- /// <summary>- /// Gets or sets the UDP server.- /// </summary>- /// <value>The UDP server.</value>- private UdpServer UdpServer { get; set; }/// <summary>/// Gets or sets the display preferences manager./// </summary>@@ -175,26 +169,11 @@ namespace MediaBrowser.ServerApplicationprivate Task<IHttpServer> _httpServerCreationTask;- /// <summary>- /// Inits this instance.- /// </summary>- /// <returns>Task.</returns>- public override async Task Init()- {- var win = new SplashWindow(ApplicationVersion);-- win.Show();-- await base.Init();-- win.Hide();- }-/// <summary>/// Runs the startup tasks./// </summary>/// <returns>Task.</returns>- protected override async Task RunStartupTasks()+ public override async Task RunStartupTasks(){await base.RunStartupTasks().ConfigureAwait(false);@@ -390,21 +369,8 @@ namespace MediaBrowser.ServerApplication() => LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IItemResolver>(), GetExports<IIntroProvider>(), GetExports<IBaseItemComparer>()),- () => ProviderManager.AddMetadataProviders(GetExports<BaseMetadataProvider>().ToArray()),+ () => ProviderManager.AddMetadataProviders(GetExports<BaseMetadataProvider>().ToArray())- () =>- {- UdpServer = new UdpServer(Logger, NetworkManager, ServerConfigurationManager);-- try- {- UdpServer.Start(UdpServerPort);- }- catch (SocketException ex)- {- Logger.ErrorException("Failed to start UDP Server", ex);- }- });}@@ -471,23 +437,6 @@ namespace MediaBrowser.ServerApplicationget { return ConfigurationManager.CommonConfiguration.EnableAutoUpdate; }}- /// <summary>- /// Releases unmanaged and - optionally - managed resources.- /// </summary>- /// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>- protected override void Dispose(bool dispose)- {- if (dispose)- {- if (UdpServer != null)- {- UdpServer.Dispose();- }- }-- base.Dispose(dispose);- }-/// <summary>/// Checks for update./// </summary>diff --git a/MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.cs b/MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.csnew file mode 100644index 0000000000..af4ce84e3e--- /dev/null+++ b/MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.cs@@ -0,0 +1,61 @@+using MediaBrowser.Common.Net;+using MediaBrowser.Controller.Configuration;+using MediaBrowser.Controller.Plugins;+using MediaBrowser.Model.Logging;+using MediaBrowser.Server.Implementations.Udp;+using System.Net.Sockets;++namespace MediaBrowser.ServerApplication.EntryPoints+{+ public class UdpServerEntryPoint : IServerEntryPoint+ {+ /// <summary>+ /// Gets or sets the UDP server.+ /// </summary>+ /// <value>The UDP server.</value>+ private UdpServer UdpServer { get; set; }++ private readonly ILogger _logger;+ private readonly INetworkManager _networkManager;+ private readonly IServerConfigurationManager _serverConfigurationManager;++ public UdpServerEntryPoint(ILogger logger, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager)+ {+ _logger = logger;+ _networkManager = networkManager;+ _serverConfigurationManager = serverConfigurationManager;+ }++ public void Run()+ {+ var udpServer = new UdpServer(_logger, _networkManager, _serverConfigurationManager);++ try+ {+ udpServer.Start(ApplicationHost.UdpServerPort);++ UdpServer = udpServer;+ }+ catch (SocketException ex)+ {+ _logger.ErrorException("Failed to start UDP Server", ex);+ }+ }++ public void Dispose()+ {+ Dispose(true);+ }++ protected virtual void Dispose(bool dispose)+ {+ if (dispose)+ {+ if (UdpServer != null)+ {+ UdpServer.Dispose();+ }+ }+ }+ }+}diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csprojindex 19b2d91ca2..7c4eb128d9 100644--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj@@ -196,6 +196,7 @@<Compile Include="EntryPoints\LoadRegistrations.cs" /><Compile Include="EntryPoints\RefreshUsersMetadata.cs" /><Compile Include="EntryPoints\StartupWizard.cs" />+ <Compile Include="EntryPoints\UdpServerEntryPoint.cs" /><Compile Include="EntryPoints\WebSocketEvents.cs" /><Compile Include="Splash\SplashWindow.xaml.cs"><DependentUpon>SplashWindow.xaml</DependentUpon>