using System;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Plugins;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Serialization;
using Emby.Server.Implementations.Udp;
using MediaBrowser.Model.Net;
namespace Emby.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;
private readonly ISocketFactory _socketFactory;
private readonly IServerApplicationHost _appHost;
private readonly IJsonSerializer _json;
public const int PortNumber = 7359;
///
/// Initializes a new instance of the class.
///
public UdpServerEntryPoint(ILogger logger, IServerApplicationHost appHost, IJsonSerializer json, ISocketFactory socketFactory)
{
_logger = logger;
_appHost = appHost;
_json = json;
_socketFactory = socketFactory;
}
///
/// Runs this instance.
///
public void Run()
{
// ToDo: Fix This
return;
var udpServer = new UdpServer(_logger, _appHost, _json, _socketFactory);
try
{
udpServer.Start(PortNumber);
UdpServer = udpServer;
}
catch (Exception ex)
{
_logger.LogError("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();
}
}
}
}
}