using MediaBrowser.Common.Net; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Plugins; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Implementations.Udp; using System.Net.Sockets; namespace MediaBrowser.Server.Implementations.EntryPoints { /// /// Class UdpServerEntryPoint /// public class UdpServerEntryPoint : IServerEntryPoint { /// /// Gets or sets the UDP server. /// /// The UDP server. private UdpServer UdpServer { get; set; } /// /// The _logger /// private readonly ILogger _logger; /// /// The _network manager /// private readonly INetworkManager _networkManager; /// /// The _server configuration manager /// private readonly IServerConfigurationManager _serverConfigurationManager; /// /// The _HTTP server /// private readonly IHttpServer _httpServer; private readonly IServerApplicationHost _appHost; public const int PortNumber = 7359; /// /// Initializes a new instance of the class. /// /// The logger. /// The network manager. /// The server configuration manager. /// The HTTP server. public UdpServerEntryPoint(ILogger logger, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager, IHttpServer httpServer, IServerApplicationHost appHost) { _logger = logger; _networkManager = networkManager; _serverConfigurationManager = serverConfigurationManager; _httpServer = httpServer; _appHost = appHost; } /// /// Runs this instance. /// public void Run() { var udpServer = new UdpServer(_logger, _networkManager, _serverConfigurationManager, _httpServer, _appHost); try { udpServer.Start(PortNumber); UdpServer = udpServer; } catch (SocketException ex) { _logger.ErrorException("Failed to start UDP Server", ex); } } /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// public void Dispose() { Dispose(true); } /// /// Releases unmanaged and - optionally - managed resources. /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. protected virtual void Dispose(bool dispose) { if (dispose) { if (UdpServer != null) { UdpServer.Dispose(); } } } } }