ISsdpCommunicationsServer.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. using MediaBrowser.Model.Net;
  5. namespace Rssdp.Infrastructure
  6. {
  7. /// <summary>
  8. /// Interface for a component that manages network communication (sending and receiving HTTPU messages) for the SSDP protocol.
  9. /// </summary>
  10. public interface ISsdpCommunicationsServer : IDisposable
  11. {
  12. #region Events
  13. /// <summary>
  14. /// Raised when a HTTPU request message is received by a socket (unicast or multicast).
  15. /// </summary>
  16. event EventHandler<RequestReceivedEventArgs> RequestReceived;
  17. /// <summary>
  18. /// Raised when an HTTPU response message is received by a socket (unicast or multicast).
  19. /// </summary>
  20. event EventHandler<ResponseReceivedEventArgs> ResponseReceived;
  21. #endregion
  22. #region Methods
  23. /// <summary>
  24. /// Causes the server to begin listening for multicast messages, being SSDP search requests and notifications.
  25. /// </summary>
  26. void BeginListeningForBroadcasts();
  27. /// <summary>
  28. /// Causes the server to stop listening for multicast messages, being SSDP search requests and notifications.
  29. /// </summary>
  30. void StopListeningForBroadcasts();
  31. /// <summary>
  32. /// Stops listening for search responses on the local, unicast socket.
  33. /// </summary>
  34. void StopListeningForResponses();
  35. /// <summary>
  36. /// Sends a message to a particular address (uni or multicast) and port.
  37. /// </summary>
  38. Task SendMessage(byte[] messageData, IpEndPointInfo destination, IpAddressInfo fromLocalIpAddress, CancellationToken cancellationToken);
  39. /// <summary>
  40. /// Sends a message to the SSDP multicast address and port.
  41. /// </summary>
  42. Task SendMulticastMessage(string message, CancellationToken cancellationToken);
  43. #endregion
  44. #region Properties
  45. /// <summary>
  46. /// Gets or sets a boolean value indicating whether or not this instance is shared amongst multiple <see cref="SsdpDeviceLocatorBase"/> and/or <see cref="ISsdpDevicePublisher"/> instances.
  47. /// </summary>
  48. /// <remarks>
  49. /// <para>If true, disposing an instance of a <see cref="SsdpDeviceLocatorBase"/>or a <see cref="ISsdpDevicePublisher"/> will not dispose this comms server instance. The calling code is responsible for managing the lifetime of the server.</para>
  50. /// </remarks>
  51. bool IsShared { get; set; }
  52. #endregion
  53. }
  54. }