Talrace.Core.SignalR
8.0.0
dotnet add package Talrace.Core.SignalR --version 8.0.0
NuGet\Install-Package Talrace.Core.SignalR -Version 8.0.0
<PackageReference Include="Talrace.Core.SignalR" Version="8.0.0" />
paket add Talrace.Core.SignalR --version 8.0.0
#r "nuget: Talrace.Core.SignalR, 8.0.0"
// Install Talrace.Core.SignalR as a Cake Addin
#addin nuget:?package=Talrace.Core.SignalR&version=8.0.0
// Install Talrace.Core.SignalR as a Cake Tool
#tool nuget:?package=Talrace.Core.SignalR&version=8.0.0
About
This package for build real-time web applications using SignalR framework in .NET Core.
It provides sets of abstractions and implementations for working with SignalR in .NET Core:
- user/connection tracking for single application instance (using In-memory user store).
- user/connection tracking for multi application instance (using Redis user store).
Available api
SignalRServiceCollectionExtensions - static class provides extension methods for the IServiceCollection interface.
IUserTracker<out THub> - interface provides methods for managing user connections.
HubWithUserTracking - class provides connection, group, and messaging management. Define a user connection tracker.
SignalR configuration
Add SignalR with in the memory user connection tracking in dependency container.
public void ConfigureServices(IServiceCollection services) {
services.AddInMemorySignalR();
}
Create a hub class inherited from HubWithUserTracking class and override GetUserTracker() method.
public class TestHub : HubWithUserTracking {
public TestHub(IServiceProvider serviceProvider) : base(serviceProvider) { }
protected override IUserTracker<HubWithUserTracking> GetUserTracker() {
return ServiceProvider.GetRequiredService<IUserTracker<TestHub>>();
}
}
Use MapHub<TestHub> to match the route for the Hub in the application.
public void Configure(IApplicationBuilder app) {
app.UseEndpoints(endpoints => {
endpoints.MapHub<TestHub>("/testhub");
});
}
SignalR with redis server configuration
Add section about redis settings to appsettings.json.
{
"RedisSettings": {
"DefaultDatabase": <DatabaseIndex>,
"EndPoints": [ "<ServerEndPoint>" ],
"Password": "<ServerPassword>",
"ChannelPrefix": "<ChannelPrefix>"
}
}
Add SignalR with Redis user connection tracking in dependency container.
public void ConfigureServices(IServiceCollection services) {
var section = Configuration.GetSection("RedisSettings");
services.AddRedisSignalR(section);
}
Create a hub class inherited from HubWithUserTracking class and override GetUserTracker() method.
public class TestHub : HubWithUserTracking {
public TestHub(IServiceProvider serviceProvider) : base(serviceProvider) { }
protected override IUserTracker<HubWithUserTracking> GetUserTracker() {
return ServiceProvider.GetRequiredService<IUserTracker<TestHub>>();
}
}
Use MapHub<TestHub> to match the route for the Hub in the application.
public void Configure(IApplicationBuilder app) {
app.UseEndpoints(endpoints => {
endpoints.MapHub<TestHub>("/testhub");
});
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.SignalR.StackExchangeRedis (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Talrace.Core.Extensions (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.