jellyfin/MediaBrowser.Controller/Net/IWebSocketConnection.cs

67 lines
2.0 KiB
C#
Raw Normal View History

using System;
2019-12-17 15:15:02 -07:00
using System.Net;
2018-12-27 16:27:57 -07:00
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Net;
using Microsoft.AspNetCore.Http;
2018-12-27 16:27:57 -07:00
namespace MediaBrowser.Controller.Net
{
public interface IWebSocketConnection : IDisposable
{
/// <summary>
/// Occurs when [closed].
/// </summary>
event EventHandler<EventArgs> Closed;
/// <summary>
/// Gets the last activity date.
/// </summary>
/// <value>The last activity date.</value>
DateTime LastActivityDate { get; }
/// <summary>
/// Gets or sets the URL.
/// </summary>
/// <value>The URL.</value>
string Url { get; set; }
2019-12-17 15:15:02 -07:00
2018-12-27 16:27:57 -07:00
/// <summary>
/// Gets or sets the query string.
/// </summary>
/// <value>The query string.</value>
IQueryCollection QueryString { get; set; }
2018-12-27 16:27:57 -07:00
/// <summary>
/// Gets or sets the receive action.
/// </summary>
/// <value>The receive action.</value>
Func<WebSocketMessageInfo, Task> OnReceive { get; set; }
/// <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-17 15:15:02 -07:00
IPAddress RemoteEndPoint { get; }
2018-12-27 16:27:57 -07: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 13:37:13 -07:00
/// <exception cref="ArgumentNullException">message</exception>
2018-12-27 16:27:57 -07:00
Task SendAsync<T>(WebSocketMessage<T> message, CancellationToken cancellationToken);
2019-12-17 15:15:02 -07:00
Task ProcessAsync(CancellationToken cancellationToken = default);
2018-12-27 16:27:57 -07:00
}
}