ISsdpCommunicationsServer.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /// Sends a message to a particular address (uni or multicast) and port.
  33. /// </summary>
  34. Task SendMessage(byte[] messageData, IpEndPointInfo destination, IpAddressInfo fromLocalIpAddress, CancellationToken cancellationToken);
  35. /// <summary>
  36. /// Sends a message to the SSDP multicast address and port.
  37. /// </summary>
  38. Task SendMulticastMessage(string message, CancellationToken cancellationToken);
  39. Task SendMulticastMessage(string message, int sendCount, CancellationToken cancellationToken);
  40. #endregion
  41. #region Properties
  42. /// <summary>
  43. /// 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.
  44. /// </summary>
  45. /// <remarks>
  46. /// <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>
  47. /// </remarks>
  48. bool IsShared { get; set; }
  49. #endregion
  50. }
  51. }