Nesco.SignalRUserManagement.Client 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Nesco.SignalRUserManagement.Client --version 1.0.0
                    
NuGet\Install-Package Nesco.SignalRUserManagement.Client -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nesco.SignalRUserManagement.Client" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nesco.SignalRUserManagement.Client" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Nesco.SignalRUserManagement.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nesco.SignalRUserManagement.Client --version 1.0.0
                    
#r "nuget: Nesco.SignalRUserManagement.Client, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nesco.SignalRUserManagement.Client@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nesco.SignalRUserManagement.Client&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Nesco.SignalRUserManagement.Client&version=1.0.0
                    
Install as a Cake Tool

Nesco.SignalRUserManagement.Client

Client-side package for connecting to SignalR User Management hubs from Blazor WebAssembly applications.

Installation

dotnet add package Nesco.SignalRUserManagement.Client

Usage

1. Configure services in Program.cs

using Nesco.SignalRUserManagement.Client.Extensions;

builder.Services.AddUserManagementClient(options =>
{
    options.BroadcastConnectionEvents = true;
    options.ConnectionEventMethod = "UserConnectionEvent";
});

2. Initialize the connection

@inject UserConnectionClient ConnectionClient

protected override async Task OnInitializedAsync()
{
    // Simple initialization
    await ConnectionClient.InitializeAsync("https://yourserver.com/hubs/messaging");

    // With authentication
    await ConnectionClient.InitializeAsync(
        "https://yourserver.com/hubs/messaging",
        async () => await GetAccessTokenAsync());

    // Subscribe to connection status changes
    ConnectionClient.ConnectionStatusChanged += OnConnectionStatusChanged;

    // Subscribe to user connection events
    ConnectionClient.UserConnectionEventReceived += OnUserConnectionEvent;

    // Register message handlers
    ConnectionClient.On<string>("ReceiveNotification", async (message) =>
    {
        Console.WriteLine($"Received: {message}");
        StateHasChanged();
    });
}

private void OnConnectionStatusChanged(bool isConnected)
{
    Console.WriteLine($"Connection status: {(isConnected ? "Connected" : "Disconnected")}");
    StateHasChanged();
}

private Task OnUserConnectionEvent(UserConnectionEventArgs eventArgs)
{
    Console.WriteLine($"User {eventArgs.UserId} {eventArgs.EventType}");
    return Task.CompletedTask;
}

3. Send messages to the server

// Send a message to the server
await ConnectionClient.SendAsync("SendMessage", "Hello server!");

// Invoke a method and get a result
var result = await ConnectionClient.InvokeAsync<string>("GetServerTime");

4. Check connection status

bool isConnected = ConnectionClient.IsConnected;
string? connectionId = ConnectionClient.ConnectionId;
var state = ConnectionClient.ConnectionState;

5. Manual reconnection

if (!ConnectionClient.IsConnected)
{
    await ConnectionClient.ReconnectAsync();
}

Complete Example

@page "/notifications"
@inject UserConnectionClient ConnectionClient
@implements IAsyncDisposable

<h3>Notifications</h3>

<p>Status: @(ConnectionClient.IsConnected ? "Connected" : "Disconnected")</p>
<p>Connection ID: @ConnectionClient.ConnectionId</p>

<ul>
    @foreach (var notification in _notifications)
    {
        <li>@notification</li>
    }
</ul>

@code {
    private List<string> _notifications = new();

    protected override async Task OnInitializedAsync()
    {
        // Initialize connection
        await ConnectionClient.InitializeAsync(
            "https://localhost:5004/hubs/messaging",
            () => Task.FromResult(AccessToken));

        // Subscribe to events
        ConnectionClient.ConnectionStatusChanged += (isConnected) =>
        {
            StateHasChanged();
        };

        // Register message handlers
        ConnectionClient.On<string>("ReceiveNotification", async (message) =>
        {
            _notifications.Add(message);
            StateHasChanged();
        });

        ConnectionClient.On<UserConnectionEventArgs>("UserConnectionEvent", async (eventArgs) =>
        {
            _notifications.Add($"User {eventArgs.UserId} {eventArgs.EventType}");
            StateHasChanged();
        });
    }

    public async ValueTask DisposeAsync()
    {
        await ConnectionClient.StopAsync();
    }
}

Features

  • Automatic Reconnection: Automatically reconnects with exponential backoff
  • Connection Events: Receive notifications when users connect/disconnect
  • Type-safe Message Handling: Register strongly-typed message handlers
  • Authentication Support: Integrate with JWT or other authentication mechanisms
  • Connection Status Monitoring: Track connection state changes in real-time
  • Manual Control: Start, stop, and reconnect as needed

Events

ConnectionStatusChanged

Raised when the connection state changes (connected/disconnected).

ConnectionClient.ConnectionStatusChanged += (isConnected) =>
{
    Console.WriteLine($"Connection: {isConnected}");
};

UserConnectionEventReceived

Raised when another user connects or disconnects (if BroadcastConnectionEvents is enabled).

ConnectionClient.UserConnectionEventReceived += async (eventArgs) =>
{
    Console.WriteLine($"{eventArgs.UserId} {eventArgs.EventType}");
};

Connection States

  • Disconnected: No connection to the server
  • Connecting: Connection is being established
  • Connected: Successfully connected and can send/receive messages
  • Reconnecting: Connection was lost and is being re-established

Notes

  • The client automatically reconnects with exponential backoff (0s, 2s, 5s, 10s)
  • All message handlers are executed asynchronously
  • The service is registered as a singleton and can be injected anywhere
  • Connection status changes trigger events that can update the UI
  • Dispose the client properly to clean up resources
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Nesco.SignalRUserManagement.Client:

Package Downloads
Nesco.SignalRCommunicator.Client.Dashboard

A ready-to-use Blazor WebAssembly dashboard component for SignalR client status, connection monitoring, and method invocation logging.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.11 462 12/10/2025
1.0.9 362 12/8/2025
1.0.8 219 12/7/2025
1.0.6 148 12/6/2025
1.0.2 678 12/2/2025
1.0.1 583 12/1/2025
1.0.0 162 11/28/2025