From 407016a30702694e39505afbb599791ed7c2dcfe Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 18 May 2013 18:07:59 -0400 Subject: get to the tray icon a little quicker --- .../EntryPoints/UdpServerEntryPoint.cs | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.cs (limited to 'MediaBrowser.ServerApplication/EntryPoints') diff --git a/MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.cs b/MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.cs new file mode 100644 index 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 + { + /// + /// Gets or sets the UDP server. + /// + /// The UDP server. + 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(); + } + } + } + } +} -- cgit v1.2.3