jellyfin/Emby.Dlna/MediaReceiverRegistrar/ControlHandler.cs

59 lines
2.2 KiB
C#
Raw Normal View History

2016-10-30 00:22:20 +02:00
using System;
using System.Collections.Generic;
using System.Xml;
2019-01-13 20:16:19 +01:00
using Emby.Dlna.Service;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using Microsoft.Extensions.Logging;
2016-10-30 00:22:20 +02:00
2016-10-30 00:34:54 +02:00
namespace Emby.Dlna.MediaReceiverRegistrar
2016-10-30 00:22:20 +02:00
{
2020-09-13 15:36:10 +02:00
/// <summary>
/// Defines the <see cref="ControlHandler" />.
/// </summary>
2016-10-30 00:22:20 +02:00
public class ControlHandler : BaseControlHandler
{
2020-09-13 15:36:10 +02:00
/// <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>
public ControlHandler(IServerConfigurationManager config, ILogger logger)
: base(config, logger)
2016-10-30 00:22:20 +02:00
{
}
/// <inheritdoc />
2021-04-01 19:16:00 +02:00
protected override void WriteResult(string methodName, IReadOnlyDictionary<string, string> methodParams, XmlWriter xmlWriter)
2016-10-30 00:22:20 +02:00
{
if (string.Equals(methodName, "IsAuthorized", StringComparison.OrdinalIgnoreCase))
2016-10-30 00:22:20 +02:00
{
HandleIsAuthorized(xmlWriter);
return;
}
2016-10-30 00:22:20 +02:00
if (string.Equals(methodName, "IsValidated", StringComparison.OrdinalIgnoreCase))
2016-10-30 00:22:20 +02:00
{
HandleIsValidated(xmlWriter);
return;
}
2016-11-04 09:31:05 +01:00
throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
2016-11-04 09:31:05 +01:00
}
2020-09-13 15:36:10 +02:00
/// <summary>
/// Records that the handle is authorized in the xml stream.
/// </summary>
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
private static void HandleIsAuthorized(XmlWriter xmlWriter)
=> xmlWriter.WriteElementString("Result", "1");
2020-09-13 15:36:10 +02:00
/// <summary>
/// Records that the handle is validated in the xml stream.
/// </summary>
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
private static void HandleIsValidated(XmlWriter xmlWriter)
=> xmlWriter.WriteElementString("Result", "1");
2016-10-30 00:22:20 +02:00
}
}