aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.cs')
-rw-r--r--MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.cs61
1 files changed, 61 insertions, 0 deletions
diff --git a/MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.cs b/MediaBrowser.ServerApplication/EntryPoints/UdpServerEntryPoint.cs
new file mode 100644
index 000000000..af4ce84e3
--- /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();
+ }
+ }
+ }
+ }
+}