ControlHandler.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Xml;
  5. using Emby.Dlna.Service;
  6. using MediaBrowser.Common.Extensions;
  7. using MediaBrowser.Controller.Configuration;
  8. using MediaBrowser.Model.Dlna;
  9. using Microsoft.Extensions.Logging;
  10. namespace Emby.Dlna.ConnectionManager
  11. {
  12. public class ControlHandler : BaseControlHandler
  13. {
  14. private readonly DeviceProfile _profile;
  15. public ControlHandler(IServerConfigurationManager config, ILogger logger, DeviceProfile profile)
  16. : base(config, logger)
  17. {
  18. _profile = profile;
  19. }
  20. /// <inheritdoc />
  21. protected override void WriteResult(string methodName, IDictionary<string, string> methodParams, XmlWriter xmlWriter)
  22. {
  23. if (string.Equals(methodName, "GetProtocolInfo", StringComparison.OrdinalIgnoreCase))
  24. {
  25. HandleGetProtocolInfo(xmlWriter);
  26. return;
  27. }
  28. throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
  29. }
  30. private void HandleGetProtocolInfo(XmlWriter xmlWriter)
  31. {
  32. xmlWriter.WriteElementString("Source", _profile.ProtocolInfo);
  33. xmlWriter.WriteElementString("Sink", string.Empty);
  34. }
  35. }
  36. }