aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Middleware/WebSocketHandlerMiddleware.cs
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2023-02-04 10:21:49 -0700
committerGitHub <noreply@github.com>2023-02-04 10:21:49 -0700
commitd1af317d98a6190711af406af17b569844aebbd7 (patch)
tree3422bb577d2821a9798465439e983932690aa2e3 /Jellyfin.Api/Middleware/WebSocketHandlerMiddleware.cs
parente0519189b25bc4605889e46d9583fea9aef41732 (diff)
parentdfea1229e12764a77f5d392194b1848f80b87042 (diff)
Merge pull request #9215 from Shadowghost/api-scoped-namespace
Diffstat (limited to 'Jellyfin.Api/Middleware/WebSocketHandlerMiddleware.cs')
-rw-r--r--Jellyfin.Api/Middleware/WebSocketHandlerMiddleware.cs51
1 files changed, 25 insertions, 26 deletions
diff --git a/Jellyfin.Api/Middleware/WebSocketHandlerMiddleware.cs b/Jellyfin.Api/Middleware/WebSocketHandlerMiddleware.cs
index 2cf1e5e4a..009fb6269 100644
--- a/Jellyfin.Api/Middleware/WebSocketHandlerMiddleware.cs
+++ b/Jellyfin.Api/Middleware/WebSocketHandlerMiddleware.cs
@@ -2,39 +2,38 @@ using System.Threading.Tasks;
using MediaBrowser.Controller.Net;
using Microsoft.AspNetCore.Http;
-namespace Jellyfin.Api.Middleware
+namespace Jellyfin.Api.Middleware;
+
+/// <summary>
+/// Handles WebSocket requests.
+/// </summary>
+public class WebSocketHandlerMiddleware
{
+ private readonly RequestDelegate _next;
+
/// <summary>
- /// Handles WebSocket requests.
+ /// Initializes a new instance of the <see cref="WebSocketHandlerMiddleware"/> class.
/// </summary>
- public class WebSocketHandlerMiddleware
+ /// <param name="next">The next delegate in the pipeline.</param>
+ public WebSocketHandlerMiddleware(RequestDelegate next)
{
- private readonly RequestDelegate _next;
+ _next = next;
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="WebSocketHandlerMiddleware"/> class.
- /// </summary>
- /// <param name="next">The next delegate in the pipeline.</param>
- public WebSocketHandlerMiddleware(RequestDelegate next)
+ /// <summary>
+ /// Executes the middleware action.
+ /// </summary>
+ /// <param name="httpContext">The current HTTP context.</param>
+ /// <param name="webSocketManager">The WebSocket connection manager.</param>
+ /// <returns>The async task.</returns>
+ public async Task Invoke(HttpContext httpContext, IWebSocketManager webSocketManager)
+ {
+ if (!httpContext.WebSockets.IsWebSocketRequest)
{
- _next = next;
+ await _next(httpContext).ConfigureAwait(false);
+ return;
}
- /// <summary>
- /// Executes the middleware action.
- /// </summary>
- /// <param name="httpContext">The current HTTP context.</param>
- /// <param name="webSocketManager">The WebSocket connection manager.</param>
- /// <returns>The async task.</returns>
- public async Task Invoke(HttpContext httpContext, IWebSocketManager webSocketManager)
- {
- if (!httpContext.WebSockets.IsWebSocketRequest)
- {
- await _next(httpContext).ConfigureAwait(false);
- return;
- }
-
- await webSocketManager.WebSocketRequestHandler(httpContext).ConfigureAwait(false);
- }
+ await webSocketManager.WebSocketRequestHandler(httpContext).ConfigureAwait(false);
}
}