2020-08-22 19:56:24 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 20:01:16 +00:00
|
|
|
using System;
|
2019-12-17 22:15:02 +00:00
|
|
|
using System.Net;
|
2018-12-27 23:27:57 +00:00
|
|
|
using System.Net.WebSockets;
|
|
|
|
using System.Threading;
|
2019-01-13 19:25:32 +00:00
|
|
|
using System.Threading.Tasks;
|
2023-07-02 22:14:44 +00:00
|
|
|
using MediaBrowser.Controller.Net.WebSocketMessages;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Net
|
|
|
|
{
|
2022-07-24 16:35:46 +00:00
|
|
|
public interface IWebSocketConnection : IAsyncDisposable, IDisposable
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [closed].
|
|
|
|
/// </summary>
|
2019-12-26 19:57:46 +00:00
|
|
|
event EventHandler<EventArgs>? Closed;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the last activity date.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The last activity date.</value>
|
|
|
|
DateTime LastActivityDate { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-04-17 11:47:00 +00:00
|
|
|
/// Gets or sets the date of last Keeplive received.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The date of last Keeplive received.</value>
|
2020-05-09 12:34:07 +00:00
|
|
|
DateTime LastKeepAliveDate { get; set; }
|
2020-04-17 11:47:00 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the receive action.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The receive action.</value>
|
2019-12-26 19:57:46 +00:00
|
|
|
Func<WebSocketMessageInfo, Task>? OnReceive { get; set; }
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the state.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The state.</value>
|
|
|
|
WebSocketState State { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the remote end point.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The remote end point.</value>
|
2019-12-26 19:57:46 +00:00
|
|
|
IPAddress? RemoteEndPoint { get; }
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2023-07-02 22:14:44 +00:00
|
|
|
/// <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);
|
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Sends a message asynchronously.
|
|
|
|
/// </summary>
|
2021-06-06 15:16:41 +00:00
|
|
|
/// <typeparam name="T">The type of websocket message data.</typeparam>
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <param name="message">The message.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
2021-06-06 15:16:41 +00:00
|
|
|
/// <exception cref="ArgumentNullException">The message is null.</exception>
|
2023-07-02 22:14:44 +00:00
|
|
|
Task SendAsync<T>(OutboundWebSocketMessage<T> message, CancellationToken cancellationToken);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2019-12-17 22:15:02 +00:00
|
|
|
Task ProcessAsync(CancellationToken cancellationToken = default);
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
}
|