2021-05-07 00:39:20 +02:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-22 21:56:24 +02:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-12-26 20:57:46 +01:00
|
|
|
#nullable enable
|
|
|
|
|
2019-01-13 21:01:16 +01:00
|
|
|
using System;
|
2019-12-17 23:15:02 +01:00
|
|
|
using System.Net;
|
2018-12-28 00:27:57 +01:00
|
|
|
using System.Net.WebSockets;
|
|
|
|
using System.Threading;
|
2019-01-13 20:25:32 +01:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using MediaBrowser.Model.Net;
|
2019-02-27 14:23:39 +01:00
|
|
|
using Microsoft.AspNetCore.Http;
|
2018-12-28 00:27:57 +01:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Net
|
|
|
|
{
|
2019-12-27 14:42:53 +01:00
|
|
|
public interface IWebSocketConnection
|
2018-12-28 00:27:57 +01:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when [closed].
|
|
|
|
/// </summary>
|
2019-12-26 20:57:46 +01:00
|
|
|
event EventHandler<EventArgs>? Closed;
|
2018-12-28 00:27:57 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the last activity date.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The last activity date.</value>
|
|
|
|
DateTime LastActivityDate { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-04-17 13:47:00 +02:00
|
|
|
/// Gets or sets the date of last Keeplive received.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The date of last Keeplive received.</value>
|
2020-05-09 14:34:07 +02:00
|
|
|
DateTime LastKeepAliveDate { get; set; }
|
2020-04-17 13:47:00 +02:00
|
|
|
|
2018-12-28 00:27:57 +01:00
|
|
|
/// <summary>
|
2021-05-11 13:55:46 +02:00
|
|
|
/// Gets the query string.
|
2018-12-28 00:27:57 +01:00
|
|
|
/// </summary>
|
|
|
|
/// <value>The query string.</value>
|
2019-12-26 20:57:46 +01:00
|
|
|
IQueryCollection QueryString { get; }
|
2018-12-28 00:27:57 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the receive action.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The receive action.</value>
|
2019-12-26 20:57:46 +01:00
|
|
|
Func<WebSocketMessageInfo, Task>? OnReceive { get; set; }
|
2018-12-28 00:27:57 +01: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 20:57:46 +01:00
|
|
|
IPAddress? RemoteEndPoint { get; }
|
2018-12-28 00:27:57 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sends a message asynchronously.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
/// <param name="message">The message.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
2019-01-13 21:37:13 +01:00
|
|
|
/// <exception cref="ArgumentNullException">message</exception>
|
2018-12-28 00:27:57 +01:00
|
|
|
Task SendAsync<T>(WebSocketMessage<T> message, CancellationToken cancellationToken);
|
|
|
|
|
2019-12-17 23:15:02 +01:00
|
|
|
Task ProcessAsync(CancellationToken cancellationToken = default);
|
2018-12-28 00:27:57 +01:00
|
|
|
}
|
|
|
|
}
|