ISsdpCommunicationsServer.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Threading.Tasks;
  3. using MediaBrowser.Model.Net;
  4. namespace Rssdp.Infrastructure
  5. {
  6. /// <summary>
  7. /// Interface for a component that manages network communication (sending and receiving HTTPU messages) for the SSDP protocol.
  8. /// </summary>
  9. public interface ISsdpCommunicationsServer : IDisposable
  10. {
  11. #region Events
  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. #endregion
  21. #region Methods
  22. /// <summary>
  23. /// Causes the server to begin listening for multicast messages, being SSDP search requests and notifications.
  24. /// </summary>
  25. void BeginListeningForBroadcasts();
  26. /// <summary>
  27. /// Causes the server to stop listening for multicast messages, being SSDP search requests and notifications.
  28. /// </summary>
  29. void StopListeningForBroadcasts();
  30. /// <summary>
  31. /// Stops listening for search responses on the local, unicast socket.
  32. /// </summary>
  33. void StopListeningForResponses();
  34. /// <summary>
  35. /// Sends a message to a particular address (uni or multicast) and port.
  36. /// </summary>
  37. /// <param name="messageData">A byte array containing the data to send.</param>
  38. /// <param name="destination">A <see cref="IpEndPointInfo"/> representing the destination address for the data. Can be either a multicast or unicast destination.</param>
  39. Task SendMessage(byte[] messageData, IpEndPointInfo destination);
  40. /// <summary>
  41. /// Sends a message to the SSDP multicast address and port.
  42. /// </summary>
  43. /// <param name="messageData">A byte array containing the data to send.</param>
  44. Task SendMulticastMessage(byte[] messageData);
  45. #endregion
  46. #region Properties
  47. /// <summary>
  48. /// 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.
  49. /// </summary>
  50. /// <remarks>
  51. /// <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>
  52. /// </remarks>
  53. bool IsShared { get; set; }
  54. #endregion
  55. }
  56. }