diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-24 20:54:51 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-24 20:54:51 -0400 |
| commit | fe5a9232c84cea113336005b3c7cbd7fe77a2d80 (patch) | |
| tree | 9fb1412f4a8ca4303ec276b6ab6e096f98eed58d /MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs | |
| parent | 0ab379e271afe69372806ab0e24a874d3f085456 (diff) | |
moved a few things for mono
Diffstat (limited to 'MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs new file mode 100644 index 000000000..9c1a953b1 --- /dev/null +++ b/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs @@ -0,0 +1,97 @@ +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.Server.Implementations.EntryPoints +{ + /// <summary> + /// Class UdpServerEntryPoint + /// </summary> + public class UdpServerEntryPoint : IServerEntryPoint + { + /// <summary> + /// Gets or sets the UDP server. + /// </summary> + /// <value>The UDP server.</value> + private UdpServer UdpServer { get; set; } + + /// <summary> + /// The _logger + /// </summary> + private readonly ILogger _logger; + /// <summary> + /// The _network manager + /// </summary> + private readonly INetworkManager _networkManager; + /// <summary> + /// The _server configuration manager + /// </summary> + private readonly IServerConfigurationManager _serverConfigurationManager; + /// <summary> + /// The _HTTP server + /// </summary> + private readonly IHttpServer _httpServer; + + public const int PortNumber = 7359; + + /// <summary> + /// Initializes a new instance of the <see cref="UdpServerEntryPoint"/> class. + /// </summary> + /// <param name="logger">The logger.</param> + /// <param name="networkManager">The network manager.</param> + /// <param name="serverConfigurationManager">The server configuration manager.</param> + /// <param name="httpServer">The HTTP server.</param> + public UdpServerEntryPoint(ILogger logger, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager, IHttpServer httpServer) + { + _logger = logger; + _networkManager = networkManager; + _serverConfigurationManager = serverConfigurationManager; + _httpServer = httpServer; + } + + /// <summary> + /// Runs this instance. + /// </summary> + public void Run() + { + var udpServer = new UdpServer(_logger, _networkManager, _serverConfigurationManager, _httpServer); + + try + { + udpServer.Start(PortNumber); + + UdpServer = udpServer; + } + catch (SocketException ex) + { + _logger.ErrorException("Failed to start UDP Server", ex); + } + } + + /// <summary> + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// </summary> + public void Dispose() + { + Dispose(true); + } + + /// <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 virtual void Dispose(bool dispose) + { + if (dispose) + { + if (UdpServer != null) + { + UdpServer.Dispose(); + } + } + } + } +} |
