< Summary - Jellyfin

Information
Class: Jellyfin.Api.Middleware.WebSocketHandlerMiddleware
Assembly: Jellyfin.Api
File(s): /srv/git/jellyfin/Jellyfin.Api/Middleware/WebSocketHandlerMiddleware.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 39
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%

File(s)

/srv/git/jellyfin/Jellyfin.Api/Middleware/WebSocketHandlerMiddleware.cs

#LineLine coverage
 1using System.Threading.Tasks;
 2using MediaBrowser.Controller.Net;
 3using Microsoft.AspNetCore.Http;
 4
 5namespace Jellyfin.Api.Middleware;
 6
 7/// <summary>
 8/// Handles WebSocket requests.
 9/// </summary>
 10public class WebSocketHandlerMiddleware
 11{
 12    private readonly RequestDelegate _next;
 13
 14    /// <summary>
 15    /// Initializes a new instance of the <see cref="WebSocketHandlerMiddleware"/> class.
 16    /// </summary>
 17    /// <param name="next">The next delegate in the pipeline.</param>
 18    public WebSocketHandlerMiddleware(RequestDelegate next)
 19    {
 2220        _next = next;
 2221    }
 22
 23    /// <summary>
 24    /// Executes the middleware action.
 25    /// </summary>
 26    /// <param name="httpContext">The current HTTP context.</param>
 27    /// <param name="webSocketManager">The WebSocket connection manager.</param>
 28    /// <returns>The async task.</returns>
 29    public async Task Invoke(HttpContext httpContext, IWebSocketManager webSocketManager)
 30    {
 31        if (!httpContext.WebSockets.IsWebSocketRequest)
 32        {
 33            await _next(httpContext).ConfigureAwait(false);
 34            return;
 35        }
 36
 37        await webSocketManager.WebSocketRequestHandler(httpContext).ConfigureAwait(false);
 38    }
 39}