diff options
Diffstat (limited to 'Emby.Dlna/ConnectionManager/ControlHandler.cs')
| -rw-r--r-- | Emby.Dlna/ConnectionManager/ControlHandler.cs | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/Emby.Dlna/ConnectionManager/ControlHandler.cs b/Emby.Dlna/ConnectionManager/ControlHandler.cs index 16211c61f..1a1790ee6 100644 --- a/Emby.Dlna/ConnectionManager/ControlHandler.cs +++ b/Emby.Dlna/ConnectionManager/ControlHandler.cs @@ -1,40 +1,55 @@ +#pragma warning disable CS1591 + using System; using System.Collections.Generic; +using System.Xml; using Emby.Dlna.Service; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Configuration; using MediaBrowser.Model.Dlna; -using MediaBrowser.Model.Xml; using Microsoft.Extensions.Logging; namespace Emby.Dlna.ConnectionManager { + /// <summary> + /// Defines the <see cref="ControlHandler" />. + /// </summary> public class ControlHandler : BaseControlHandler { private readonly DeviceProfile _profile; - protected override IEnumerable<KeyValuePair<string, string>> GetResult(string methodName, IDictionary<string, string> methodParams) + /// <summary> + /// Initializes a new instance of the <see cref="ControlHandler"/> class. + /// </summary> + /// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ControlHandler"/> instance.</param> + /// <param name="logger">The <see cref="ILogger"/> for use with the <see cref="ControlHandler"/> instance.</param> + /// <param name="profile">The <see cref="DeviceProfile"/> for use with the <see cref="ControlHandler"/> instance.</param> + public ControlHandler(IServerConfigurationManager config, ILogger logger, DeviceProfile profile) + : base(config, logger) + { + _profile = profile; + } + + /// <inheritdoc /> + protected override void WriteResult(string methodName, IReadOnlyDictionary<string, string> methodParams, XmlWriter xmlWriter) { if (string.Equals(methodName, "GetProtocolInfo", StringComparison.OrdinalIgnoreCase)) { - return HandleGetProtocolInfo(); + HandleGetProtocolInfo(xmlWriter); + return; } throw new ResourceNotFoundException("Unexpected control request name: " + methodName); } - private IEnumerable<KeyValuePair<string, string>> HandleGetProtocolInfo() + /// <summary> + /// Builds the response to the GetProtocolInfo request. + /// </summary> + /// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param> + private void HandleGetProtocolInfo(XmlWriter xmlWriter) { - return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) - { - { "Source", _profile.ProtocolInfo }, - { "Sink", "" } - }; - } - - public ControlHandler(IServerConfigurationManager config, ILogger logger, IXmlReaderSettingsFactory xmlReaderSettingsFactory, DeviceProfile profile) : base(config, logger, xmlReaderSettingsFactory) - { - _profile = profile; + xmlWriter.WriteElementString("Source", _profile.ProtocolInfo); + xmlWriter.WriteElementString("Sink", string.Empty); } } } |
