ISsdpCommunicationsServer.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Net;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  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. /// <summary>
  13. /// Raised when a HTTPU request message is received by a socket (unicast or multicast).
  14. /// </summary>
  15. event EventHandler<RequestReceivedEventArgs> RequestReceived;
  16. /// <summary>
  17. /// Raised when an HTTPU response message is received by a socket (unicast or multicast).
  18. /// </summary>
  19. event EventHandler<ResponseReceivedEventArgs> ResponseReceived;
  20. /// <summary>
  21. /// Causes the server to begin listening for multicast messages, being SSDP search requests and notifications.
  22. /// </summary>
  23. void BeginListeningForBroadcasts();
  24. /// <summary>
  25. /// Causes the server to stop listening for multicast messages, being SSDP search requests and notifications.
  26. /// </summary>
  27. void StopListeningForBroadcasts();
  28. /// <summary>
  29. /// Sends a message to a particular address (uni or multicast) and port.
  30. /// </summary>
  31. Task SendMessage(byte[] messageData, IPEndPoint destination, IPAddress fromLocalIpAddress, CancellationToken cancellationToken);
  32. /// <summary>
  33. /// Sends a message to the SSDP multicast address and port.
  34. /// </summary>
  35. Task SendMulticastMessage(string message, IPAddress fromLocalIpAddress, CancellationToken cancellationToken);
  36. Task SendMulticastMessage(string message, int sendCount, IPAddress fromLocalIpAddress, CancellationToken cancellationToken);
  37. /// <summary>
  38. /// 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.
  39. /// </summary>
  40. /// <remarks>
  41. /// <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>
  42. /// </remarks>
  43. bool IsShared { get; set; }
  44. }
  45. }