using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
namespace Rssdp.Infrastructure
{
///
/// Interface for a component that manages network communication (sending and receiving HTTPU messages) for the SSDP protocol.
///
public interface ISsdpCommunicationsServer : IDisposable
{
///
/// 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;
///
/// Causes the server to begin listening for multicast messages, being SSDP search requests and notifications.
///
void BeginListeningForMulticast();
///
/// Causes the server to stop listening for multicast messages, being SSDP search requests and notifications.
///
void StopListeningForMulticast();
///
/// Sends a message to a particular address (uni or multicast) and port.
///
Task SendMessage(byte[] messageData, IPEndPoint destination, IPAddress fromLocalIpAddress, CancellationToken cancellationToken);
///
/// Sends a message to the SSDP multicast address and port.
///
Task SendMulticastMessage(string message, IPAddress fromLocalIpAddress, CancellationToken cancellationToken);
Task SendMulticastMessage(string message, int sendCount, IPAddress fromLocalIpAddress, CancellationToken cancellationToken);
///
/// 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; }
}
}