diff options
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/WebSocketConnection.cs')
| -rw-r--r-- | Emby.Server.Implementations/HttpServer/WebSocketConnection.cs | 110 |
1 files changed, 57 insertions, 53 deletions
diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index 54a16040f..2292d86a4 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -7,7 +7,6 @@ using Emby.Server.Implementations.Net; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Net; using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Services; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using UtfUnknown; @@ -15,60 +14,24 @@ using UtfUnknown; namespace Emby.Server.Implementations.HttpServer { /// <summary> - /// Class WebSocketConnection + /// Class WebSocketConnection. /// </summary> public class WebSocketConnection : IWebSocketConnection { - public event EventHandler<EventArgs> Closed; - - /// <summary> - /// The _socket - /// </summary> - private readonly IWebSocket _socket; - /// <summary> - /// The _remote end point - /// </summary> - public string RemoteEndPoint { get; private set; } - - /// <summary> - /// The logger + /// The logger. /// </summary> private readonly ILogger _logger; /// <summary> - /// The _json serializer + /// The json serializer. /// </summary> private readonly IJsonSerializer _jsonSerializer; /// <summary> - /// Gets or sets the receive action. - /// </summary> - /// <value>The receive action.</value> - public Func<WebSocketMessageInfo, Task> OnReceive { get; set; } - - /// <summary> - /// Gets the last activity date. - /// </summary> - /// <value>The last activity date.</value> - public DateTime LastActivityDate { get; private set; } - - /// <summary> - /// Gets the id. + /// The socket. /// </summary> - /// <value>The id.</value> - public Guid Id { get; private set; } - - /// <summary> - /// Gets or sets the URL. - /// </summary> - /// <value>The URL.</value> - public string Url { get; set; } - /// <summary> - /// Gets or sets the query string. - /// </summary> - /// <value>The query string.</value> - public IQueryCollection QueryString { get; set; } + private readonly IWebSocket _socket; /// <summary> /// Initializes a new instance of the <see cref="WebSocketConnection" /> class. @@ -84,14 +47,17 @@ namespace Emby.Server.Implementations.HttpServer { throw new ArgumentNullException(nameof(socket)); } + if (string.IsNullOrEmpty(remoteEndPoint)) { throw new ArgumentNullException(nameof(remoteEndPoint)); } + if (jsonSerializer == null) { throw new ArgumentNullException(nameof(jsonSerializer)); } + if (logger == null) { throw new ArgumentNullException(nameof(logger)); @@ -105,10 +71,54 @@ namespace Emby.Server.Implementations.HttpServer RemoteEndPoint = remoteEndPoint; _logger = logger; - socket.Closed += socket_Closed; + socket.Closed += OnSocketClosed; } - void socket_Closed(object sender, EventArgs e) + /// <inheritdoc /> + public event EventHandler<EventArgs> Closed; + + /// <summary> + /// Gets or sets the remote end point. + /// </summary> + public string RemoteEndPoint { get; private set; } + + /// <summary> + /// Gets or sets the receive action. + /// </summary> + /// <value>The receive action.</value> + public Func<WebSocketMessageInfo, Task> OnReceive { get; set; } + + /// <summary> + /// Gets the last activity date. + /// </summary> + /// <value>The last activity date.</value> + public DateTime LastActivityDate { get; private set; } + + /// <summary> + /// Gets the id. + /// </summary> + /// <value>The id.</value> + public Guid Id { get; private set; } + + /// <summary> + /// Gets or sets the URL. + /// </summary> + /// <value>The URL.</value> + public string Url { get; set; } + + /// <summary> + /// Gets or sets the query string. + /// </summary> + /// <value>The query string.</value> + public IQueryCollection QueryString { get; set; } + + /// <summary> + /// Gets the state. + /// </summary> + /// <value>The state.</value> + public WebSocketState State => _socket.State; + + void OnSocketClosed(object sender, EventArgs e) { Closed?.Invoke(this, EventArgs.Empty); } @@ -210,6 +220,7 @@ namespace Emby.Server.Implementations.HttpServer return _socket.SendAsync(buffer, true, cancellationToken); } + /// <inheritdoc /> public Task SendAsync(string text, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(text)) @@ -222,18 +233,11 @@ namespace Emby.Server.Implementations.HttpServer return _socket.SendAsync(text, true, cancellationToken); } - /// <summary> - /// Gets the state. - /// </summary> - /// <value>The state.</value> - public WebSocketState State => _socket.State; - - /// <summary> - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// </summary> + /// <inheritdoc /> public void Dispose() { Dispose(true); + GC.SuppressFinalize(this); } /// <summary> |
