< Summary - Syki

Information
Class: Syki.Front.Auth.SignalRConnectionManager
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Auth/SignalRConnectionManager.cs
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 23
Coverable lines: 23
Total lines: 42
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
StartAsync()0%2040%
StopAsync()0%620%

File(s)

/home/runner/work/syki/syki/Front/Auth/SignalRConnectionManager.cs

#LineLine coverage
 1using Microsoft.JSInterop;
 2using Microsoft.AspNetCore.Components;
 3using Microsoft.AspNetCore.SignalR.Client;
 4
 5namespace Syki.Front.Auth;
 6
 07public class SignalRConnectionManager(
 08    IConfiguration configuration,
 09    ILocalStorageService storage,
 010    SykiAuthStateProvider auth,
 011    NavigationManager nav)
 12{
 13    private HubConnection? _hubConnection;
 14
 15    public async Task StartAsync()
 16    {
 017        if (_hubConnection is not null && _hubConnection.State != HubConnectionState.Disconnected)
 018            return;
 19
 020        var apiUrl = configuration.GetSection("ApiUrl").Value!;
 021        _hubConnection = new HubConnectionBuilder()
 022            .WithUrl($"{apiUrl}/syki-hub", options =>
 023            {
 024                options.HttpMessageHandlerFactory = innerHandler =>
 025                new SykiDelegatingHandler(storage, auth, nav).WithInnerHandler(innerHandler);
 026            })
 027            .WithAutomaticReconnect()
 028            .Build();
 29
 030        await _hubConnection.StartAsync();
 031    }
 32
 33    public async Task StopAsync()
 34    {
 035        if (_hubConnection is not null)
 36        {
 037            await _hubConnection.StopAsync();
 038            await _hubConnection.DisposeAsync();
 039            _hubConnection = null;
 40        }
 041    }
 42}