Merge pull request #9875 from Shadowghost/fixes

This commit is contained in:
Bond-009
2023-08-01 20:26:21 +02:00
committed by GitHub
16 changed files with 198 additions and 55 deletions

View File

@@ -0,0 +1,60 @@
using System;
using MediaBrowser.Controller.Session;
namespace MediaBrowser.Controller.Events.Authentication;
/// <summary>
/// A class representing an authentication result event.
/// </summary>
public class AuthenticationRequestEventArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationRequestEventArgs"/> class.
/// </summary>
/// <param name="request">The <see cref="AuthenticationRequest"/>.</param>
public AuthenticationRequestEventArgs(AuthenticationRequest request)
{
Username = request.Username;
UserId = request.UserId;
App = request.App;
AppVersion = request.AppVersion;
DeviceId = request.DeviceId;
DeviceName = request.DeviceName;
RemoteEndPoint = request.RemoteEndPoint;
}
/// <summary>
/// Gets or sets the user name.
/// </summary>
public string? Username { get; set; }
/// <summary>
/// Gets or sets the user id.
/// </summary>
public Guid? UserId { get; set; }
/// <summary>
/// Gets or sets the app.
/// </summary>
public string? App { get; set; }
/// <summary>
/// Gets or sets the app version.
/// </summary>
public string? AppVersion { get; set; }
/// <summary>
/// Gets or sets the device id.
/// </summary>
public string? DeviceId { get; set; }
/// <summary>
/// Gets or sets the device name.
/// </summary>
public string? DeviceName { get; set; }
/// <summary>
/// Gets or sets the remote endpoint.
/// </summary>
public string? RemoteEndPoint { get; set; }
}

View File

@@ -0,0 +1,38 @@
using System;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dto;
namespace MediaBrowser.Controller.Events.Authentication;
/// <summary>
/// A class representing an authentication result event.
/// </summary>
public class AuthenticationResultEventArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationResultEventArgs"/> class.
/// </summary>
/// <param name="result">The <see cref="AuthenticationResult"/>.</param>
public AuthenticationResultEventArgs(AuthenticationResult result)
{
User = result.User;
SessionInfo = result.SessionInfo;
ServerId = result.ServerId;
}
/// <summary>
/// Gets or sets the user.
/// </summary>
public UserDto User { get; set; }
/// <summary>
/// Gets or sets the session information.
/// </summary>
public SessionInfo? SessionInfo { get; set; }
/// <summary>
/// Gets or sets the server id.
/// </summary>
public string? ServerId { get; set; }
}

View File

@@ -96,7 +96,7 @@ namespace MediaBrowser.Controller.Net
/// Starts sending messages over a web socket.
/// </summary>
/// <param name="message">The message.</param>
private void Start(WebSocketMessageInfo message)
protected virtual void Start(WebSocketMessageInfo message)
{
var vals = message.Data.Split(',');

View File

@@ -1,5 +1,3 @@
#pragma warning disable CS1591
using System;
using System.Net;
using System.Net.WebSockets;
@@ -9,6 +7,9 @@ using MediaBrowser.Controller.Net.WebSocketMessages;
namespace MediaBrowser.Controller.Net
{
/// <summary>
/// Interface for WebSocket connections.
/// </summary>
public interface IWebSocketConnection : IAsyncDisposable, IDisposable
{
/// <summary>
@@ -40,6 +41,11 @@ namespace MediaBrowser.Controller.Net
/// <value>The state.</value>
WebSocketState State { get; }
/// <summary>
/// Gets the authorization information.
/// </summary>
public AuthorizationInfo AuthorizationInfo { get; }
/// <summary>
/// Gets the remote end point.
/// </summary>
@@ -65,6 +71,11 @@ namespace MediaBrowser.Controller.Net
/// <exception cref="ArgumentNullException">The message is null.</exception>
Task SendAsync<T>(OutboundWebSocketMessage<T> message, CancellationToken cancellationToken);
Task ProcessAsync(CancellationToken cancellationToken = default);
/// <summary>
/// Receives a message asynchronously.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task ReceiveAsync(CancellationToken cancellationToken = default);
}
}