separate event managers
This commit is contained in:
parent
1774e5b1ac
commit
da943ebe99
|
@ -50,8 +50,14 @@ namespace MediaBrowser.Api.Dlna
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/Dlna/contentdirectory/{UuId}/events", Summary = "Processes an event subscription request")]
|
[Route("/Dlna/contentdirectory/{UuId}/events", Summary = "Processes an event subscription request")]
|
||||||
|
public class ProcessContentDirectoryEventRequest
|
||||||
|
{
|
||||||
|
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||||
|
public string UuId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
[Route("/Dlna/connectionmanager/{UuId}/events", Summary = "Processes an event subscription request")]
|
[Route("/Dlna/connectionmanager/{UuId}/events", Summary = "Processes an event subscription request")]
|
||||||
public class ProcessEventRequest
|
public class ProcessConnectionManagerEventRequest
|
||||||
{
|
{
|
||||||
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
|
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||||
public string UuId { get; set; }
|
public string UuId { get; set; }
|
||||||
|
@ -68,14 +74,12 @@ namespace MediaBrowser.Api.Dlna
|
||||||
{
|
{
|
||||||
private readonly IDlnaManager _dlnaManager;
|
private readonly IDlnaManager _dlnaManager;
|
||||||
private readonly IContentDirectory _contentDirectory;
|
private readonly IContentDirectory _contentDirectory;
|
||||||
private readonly IEventManager _eventManager;
|
|
||||||
private readonly IConnectionManager _connectionManager;
|
private readonly IConnectionManager _connectionManager;
|
||||||
|
|
||||||
public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDirectory, IEventManager eventManager, IConnectionManager connectionManager)
|
public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDirectory, IConnectionManager connectionManager)
|
||||||
{
|
{
|
||||||
_dlnaManager = dlnaManager;
|
_dlnaManager = dlnaManager;
|
||||||
_contentDirectory = contentDirectory;
|
_contentDirectory = contentDirectory;
|
||||||
_eventManager = eventManager;
|
|
||||||
_connectionManager = connectionManager;
|
_connectionManager = connectionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +162,17 @@ namespace MediaBrowser.Api.Dlna
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Any(ProcessEventRequest request)
|
public object Any(ProcessContentDirectoryEventRequest request)
|
||||||
|
{
|
||||||
|
return ProcessEventRequest(_contentDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Any(ProcessConnectionManagerEventRequest request)
|
||||||
|
{
|
||||||
|
return ProcessEventRequest(_connectionManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
private object ProcessEventRequest(IEventManager eventManager)
|
||||||
{
|
{
|
||||||
var subscriptionId = GetHeader("SID");
|
var subscriptionId = GetHeader("SID");
|
||||||
var notificationType = GetHeader("NT");
|
var notificationType = GetHeader("NT");
|
||||||
|
@ -171,13 +185,13 @@ namespace MediaBrowser.Api.Dlna
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(notificationType))
|
if (string.IsNullOrEmpty(notificationType))
|
||||||
{
|
{
|
||||||
return GetSubscriptionResponse(_eventManager.RenewEventSubscription(subscriptionId, timeout));
|
return GetSubscriptionResponse(eventManager.RenewEventSubscription(subscriptionId, timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetSubscriptionResponse(_eventManager.CreateEventSubscription(notificationType, timeout, callback));
|
return GetSubscriptionResponse(eventManager.CreateEventSubscription(notificationType, timeout, callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetSubscriptionResponse(_eventManager.CancelEventSubscription(subscriptionId));
|
return GetSubscriptionResponse(eventManager.CancelEventSubscription(subscriptionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private object GetSubscriptionResponse(EventSubscriptionResponse response)
|
private object GetSubscriptionResponse(EventSubscriptionResponse response)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Dlna
|
namespace MediaBrowser.Controller.Dlna
|
||||||
{
|
{
|
||||||
public interface IConnectionManager : IUpnpService
|
public interface IConnectionManager : IEventManager, IUpnpService
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Dlna
|
namespace MediaBrowser.Controller.Dlna
|
||||||
{
|
{
|
||||||
public interface IContentDirectory : IUpnpService
|
public interface IContentDirectory : IEventManager, IUpnpService
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
using MediaBrowser.Model.Dlna;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Dlna
|
namespace MediaBrowser.Controller.Dlna
|
||||||
{
|
{
|
||||||
public interface IEventManager
|
public interface IEventManager
|
||||||
|
@ -28,20 +25,5 @@ namespace MediaBrowser.Controller.Dlna
|
||||||
/// <param name="callbackUrl">The callback URL.</param>
|
/// <param name="callbackUrl">The callback URL.</param>
|
||||||
/// <returns>EventSubscriptionResponse.</returns>
|
/// <returns>EventSubscriptionResponse.</returns>
|
||||||
EventSubscriptionResponse CreateEventSubscription(string notificationType, int? timeoutSeconds, string callbackUrl);
|
EventSubscriptionResponse CreateEventSubscription(string notificationType, int? timeoutSeconds, string callbackUrl);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the subscription.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">The identifier.</param>
|
|
||||||
/// <returns>EventSubscription.</returns>
|
|
||||||
EventSubscription GetSubscription(string id);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Triggers the event.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="notificationType">Type of the notification.</param>
|
|
||||||
/// <param name="stateVariables">The state variables.</param>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
Task TriggerEvent(string notificationType, IDictionary<string,string> stateVariables);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,24 @@
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Dlna;
|
using MediaBrowser.Controller.Dlna;
|
||||||
|
using MediaBrowser.Dlna.Service;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MediaBrowser.Dlna.ConnectionManager
|
namespace MediaBrowser.Dlna.ConnectionManager
|
||||||
{
|
{
|
||||||
public class ConnectionManager : IConnectionManager
|
public class ConnectionManager : BaseService, IConnectionManager
|
||||||
{
|
{
|
||||||
private readonly IDlnaManager _dlna;
|
private readonly IDlnaManager _dlna;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
|
|
||||||
public ConnectionManager(IDlnaManager dlna, ILogManager logManager, IServerConfigurationManager config)
|
public ConnectionManager(IDlnaManager dlna, IServerConfigurationManager config, ILogger logger, IHttpClient httpClient)
|
||||||
|
: base(logger, httpClient)
|
||||||
{
|
{
|
||||||
_dlna = dlna;
|
_dlna = dlna;
|
||||||
_config = config;
|
_config = config;
|
||||||
_logger = logManager.GetLogger("UpnpConnectionManager");
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetServiceXml(IDictionary<string, string> headers)
|
public string GetServiceXml(IDictionary<string, string> headers)
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Dlna;
|
using MediaBrowser.Controller.Dlna;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Dlna.Service;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System;
|
using System;
|
||||||
|
@ -12,9 +14,8 @@ using System.Linq;
|
||||||
|
|
||||||
namespace MediaBrowser.Dlna.ContentDirectory
|
namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
{
|
{
|
||||||
public class ContentDirectory : IContentDirectory, IDisposable
|
public class ContentDirectory : BaseService, IContentDirectory, IDisposable
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private readonly IDtoService _dtoService;
|
private readonly IDtoService _dtoService;
|
||||||
private readonly IImageProcessor _imageProcessor;
|
private readonly IImageProcessor _imageProcessor;
|
||||||
|
@ -23,17 +24,16 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
|
|
||||||
private readonly IEventManager _eventManager;
|
|
||||||
|
|
||||||
public ContentDirectory(IDlnaManager dlna,
|
public ContentDirectory(IDlnaManager dlna,
|
||||||
IUserDataManager userDataManager,
|
IUserDataManager userDataManager,
|
||||||
IImageProcessor imageProcessor,
|
IImageProcessor imageProcessor,
|
||||||
IDtoService dtoService,
|
IDtoService dtoService,
|
||||||
ILibraryManager libraryManager,
|
ILibraryManager libraryManager,
|
||||||
ILogManager logManager,
|
|
||||||
IServerConfigurationManager config,
|
IServerConfigurationManager config,
|
||||||
IUserManager userManager,
|
IUserManager userManager,
|
||||||
IEventManager eventManager)
|
ILogger logger,
|
||||||
|
IHttpClient httpClient)
|
||||||
|
: base(logger, httpClient)
|
||||||
{
|
{
|
||||||
_dlna = dlna;
|
_dlna = dlna;
|
||||||
_userDataManager = userDataManager;
|
_userDataManager = userDataManager;
|
||||||
|
@ -42,8 +42,6 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_config = config;
|
_config = config;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_eventManager = eventManager;
|
|
||||||
_logger = logManager.GetLogger("UpnpContentDirectory");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int SystemUpdateId
|
private int SystemUpdateId
|
||||||
|
@ -71,7 +69,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
var user = GetUser(profile);
|
var user = GetUser(profile);
|
||||||
|
|
||||||
return new ControlHandler(
|
return new ControlHandler(
|
||||||
_logger,
|
Logger,
|
||||||
_libraryManager,
|
_libraryManager,
|
||||||
profile,
|
profile,
|
||||||
serverAddress,
|
serverAddress,
|
||||||
|
|
|
@ -21,10 +21,10 @@ namespace MediaBrowser.Dlna.Eventing
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IHttpClient _httpClient;
|
private readonly IHttpClient _httpClient;
|
||||||
|
|
||||||
public EventManager(ILogManager logManager, IHttpClient httpClient)
|
public EventManager(ILogger logger, IHttpClient httpClient)
|
||||||
{
|
{
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
_logger = logManager.GetLogger("DlnaEventManager");
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, int? timeoutSeconds)
|
public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, int? timeoutSeconds)
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
<Compile Include="ContentDirectory\ServiceActionListBuilder.cs" />
|
<Compile Include="ContentDirectory\ServiceActionListBuilder.cs" />
|
||||||
<Compile Include="ContentDirectory\ContentDirectoryXmlBuilder.cs" />
|
<Compile Include="ContentDirectory\ContentDirectoryXmlBuilder.cs" />
|
||||||
<Compile Include="Service\BaseControlHandler.cs" />
|
<Compile Include="Service\BaseControlHandler.cs" />
|
||||||
|
<Compile Include="Service\BaseService.cs" />
|
||||||
<Compile Include="Service\ControlErrorHandler.cs" />
|
<Compile Include="Service\ControlErrorHandler.cs" />
|
||||||
<Compile Include="Service\ServiceXmlBuilder.cs" />
|
<Compile Include="Service\ServiceXmlBuilder.cs" />
|
||||||
<Compile Include="Ssdp\Datagram.cs" />
|
<Compile Include="Ssdp\Datagram.cs" />
|
||||||
|
|
37
MediaBrowser.Dlna/Service/BaseService.cs
Normal file
37
MediaBrowser.Dlna/Service/BaseService.cs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Controller.Dlna;
|
||||||
|
using MediaBrowser.Dlna.Eventing;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Dlna.Service
|
||||||
|
{
|
||||||
|
public class BaseService : IEventManager
|
||||||
|
{
|
||||||
|
protected IEventManager EventManager;
|
||||||
|
protected IHttpClient HttpClient;
|
||||||
|
protected ILogger Logger;
|
||||||
|
|
||||||
|
protected BaseService(ILogger logger, IHttpClient httpClient)
|
||||||
|
{
|
||||||
|
Logger = logger;
|
||||||
|
HttpClient = httpClient;
|
||||||
|
|
||||||
|
EventManager = new EventManager(Logger, HttpClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventSubscriptionResponse CancelEventSubscription(string subscriptionId)
|
||||||
|
{
|
||||||
|
return EventManager.CancelEventSubscription(subscriptionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, int? timeoutSeconds)
|
||||||
|
{
|
||||||
|
return EventManager.RenewEventSubscription(subscriptionId, timeoutSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventSubscriptionResponse CreateEventSubscription(string notificationType, int? timeoutSeconds, string callbackUrl)
|
||||||
|
{
|
||||||
|
return EventManager.CreateEventSubscription(notificationType, timeoutSeconds, callbackUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -522,13 +522,10 @@ namespace MediaBrowser.ServerApplication
|
||||||
var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LogManager.GetLogger("Dlna"), JsonSerializer);
|
var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LogManager.GetLogger("Dlna"), JsonSerializer);
|
||||||
RegisterSingleInstance<IDlnaManager>(dlnaManager);
|
RegisterSingleInstance<IDlnaManager>(dlnaManager);
|
||||||
|
|
||||||
var dlnaEventManager = new EventManager(LogManager, HttpClient);
|
var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, DtoService, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient);
|
||||||
RegisterSingleInstance<IEventManager>(dlnaEventManager);
|
|
||||||
|
|
||||||
var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, DtoService, LibraryManager, LogManager, ServerConfigurationManager, UserManager, dlnaEventManager);
|
|
||||||
RegisterSingleInstance<IContentDirectory>(contentDirectory);
|
RegisterSingleInstance<IContentDirectory>(contentDirectory);
|
||||||
|
|
||||||
var connectionManager = new ConnectionManager(dlnaManager, LogManager, ServerConfigurationManager);
|
var connectionManager = new ConnectionManager(dlnaManager, ServerConfigurationManager, LogManager.GetLogger("UpnpConnectionManager"), HttpClient);
|
||||||
RegisterSingleInstance<IConnectionManager>(connectionManager);
|
RegisterSingleInstance<IConnectionManager>(connectionManager);
|
||||||
|
|
||||||
var collectionManager = new CollectionManager(LibraryManager, FileSystemManager, LibraryMonitor);
|
var collectionManager = new CollectionManager(LibraryManager, FileSystemManager, LibraryMonitor);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user