You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Controller/Net/IWebSocketConnection.cs

82 lines
2.8 KiB

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