Open.SignalR.SharedClient
1.0.2-preview
This is a prerelease version of Open.SignalR.SharedClient.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Open.SignalR.SharedClient --version 1.0.2-preview
NuGet\Install-Package Open.SignalR.SharedClient -Version 1.0.2-preview
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="Open.SignalR.SharedClient" Version="1.0.2-preview" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Open.SignalR.SharedClient --version 1.0.2-preview
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Open.SignalR.SharedClient, 1.0.2-preview"
#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.
// Install Open.SignalR.SharedClient as a Cake Addin #addin nuget:?package=Open.SignalR.SharedClient&version=1.0.2-preview&prerelease // Install Open.SignalR.SharedClient as a Cake Tool #tool nuget:?package=Open.SignalR.SharedClient&version=1.0.2-preview&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Open.SignalR.SharedClient
A scoped hub connection and provider for easily sharing SignalR connections.
Interfaces
IScopedHubConnection
Provides all the same functionality as a HubConnection
,
but does not interfere with other IScopedHubConnection
instances.
Disposing the scoped connection cleans up all the handlers but leaves the connection intact for others to use.
IScopedHubConnectionProvider
Usage
DI Setup
services.AddSingleton<IScopedHubConnectionProvider, ScopedHubConnectionProvider>();
Example
public class MyService : IDisposable
{
private readonly IScopedHubConnection _hub;
public MyService(IScopedHubConnectionProvider connectionProvider)
{
_hub = connectionProvider.GetConnectionFor("http://localhost:5000/hub");
_hub.On("MyMethod1", (string arg1, string arg2) =>
{
// Do something when the method is invoked on the hub.
});
_hub.On("MyMethod2", (string arg1, string arg2) =>
{
// Do something when the method is invoked on the hub.
});
// Automatically invokes OnConnectionEstablished when a connnection is available
// and invokes it on every reconnection.
_hub.OnConnected(OnConnectionEstablished);
}
public void Dispose() => _hub.Dispose();
static void OnConnectionEstablished(IScopedHubConnection hub)
{
hub.SendAsync("SubTo", "MyMethod1");
hub.SendAsync("SubTo", "MyMethod2");
}
public async Task DoSomething()
{
// Automatically guarantees a connection and invokes the method.
await _hub.InvokeAsync("MyMethod", "arg1", "arg2");
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.AspNetCore.SignalR.Client (>= 9.0.1)
- Microsoft.Testing.Extensions.CodeCoverage (>= 17.13.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.0 | 66 | 2/13/2025 |
1.1.0 | 75 | 2/11/2025 |
1.0.3 | 74 | 2/9/2025 |
1.0.2-preview | 72 | 2/9/2025 |
1.0.1-preview | 68 | 2/9/2025 |
1.0.0-preview | 58 | 2/8/2025 |