using System;
using System.Threading.Tasks;
using MediaBrowser.Model.Net;
namespace Rssdp.Infrastructure
{
///
/// Interface for a component that manages network communication (sending and receiving HTTPU messages) for the SSDP protocol.
///
public interface ISsdpCommunicationsServer : IDisposable
{
#region Events
///
/// Raised when a HTTPU request message is received by a socket (unicast or multicast).
///
event EventHandler RequestReceived;
///
/// Raised when an HTTPU response message is received by a socket (unicast or multicast).
///
event EventHandler ResponseReceived;
#endregion
#region Methods
///
/// Causes the server to begin listening for multicast messages, being SSDP search requests and notifications.
///
void BeginListeningForBroadcasts();
///
/// Causes the server to stop listening for multicast messages, being SSDP search requests and notifications.
///
void StopListeningForBroadcasts();
///
/// Stops listening for search responses on the local, unicast socket.
///
void StopListeningForResponses();
///
/// Sends a message to a particular address (uni or multicast) and port.
///
/// A byte array containing the data to send.
/// A representing the destination address for the data. Can be either a multicast or unicast destination.
Task SendMessage(byte[] messageData, IpEndPointInfo destination);
///
/// Sends a message to the SSDP multicast address and port.
///
Task SendMulticastMessage(string message);
#endregion
#region Properties
///
/// Gets or sets a boolean value indicating whether or not this instance is shared amongst multiple and/or instances.
///
///
/// If true, disposing an instance of a or a will not dispose this comms server instance. The calling code is responsible for managing the lifetime of the server.
///
bool IsShared { get; set; }
#endregion
}
}