using System;
using System.Net;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Net.WebSocketMessages;
namespace MediaBrowser.Controller.Net
{
///
/// Interface for WebSocket connections.
///
public interface IWebSocketConnection : IAsyncDisposable, IDisposable
{
///
/// Occurs when [closed].
///
event EventHandler? Closed;
///
/// Gets the last activity date.
///
/// The last activity date.
DateTime LastActivityDate { get; }
///
/// Gets or sets the date of last Keeplive received.
///
/// The date of last Keeplive received.
DateTime LastKeepAliveDate { get; set; }
///
/// Gets or sets the receive action.
///
/// The receive action.
Func? OnReceive { get; set; }
///
/// Gets the state.
///
/// The state.
WebSocketState State { get; }
///
/// Gets the authorization information.
///
public AuthorizationInfo AuthorizationInfo { get; }
///
/// Gets the remote end point.
///
/// The remote end point.
IPAddress? RemoteEndPoint { get; }
///
/// Sends a message asynchronously.
///
/// The message.
/// The cancellation token.
/// Task.
/// The message is null.
Task SendAsync(OutboundWebSocketMessage message, CancellationToken cancellationToken);
///
/// Sends a message asynchronously.
///
/// The type of websocket message data.
/// The message.
/// The cancellation token.
/// Task.
/// The message is null.
Task SendAsync(OutboundWebSocketMessage message, CancellationToken cancellationToken);
///
/// Receives a message asynchronously.
///
/// The cancellation token.
/// Task.
Task ReceiveAsync(CancellationToken cancellationToken = default);
}
}