Adds real-time SignalR features to an ABP app using Volo.Abp.AspNetCore.SignalR module: hubs, routes, authorization, and client connections.
Ships in abp-realtime. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
ABP's Volo.Abp.AspNetCore.SignalR module wraps ASP.NET Core SignalR so you don't
have to call services.AddSignalR() or map hub endpoints manually — ABP auto-registers
every hub in DI (as transient) and maps its endpoint conventionally.
CurrentUser / CurrentTenant / localization.[Authorize] and targeting connected users by id.Add the package to the web/API layer that hosts your hubs:
abp add-package Volo.Abp.AspNetCore.SignalR
Or add the NuGet package Volo.Abp.AspNetCore.SignalR and depend on the module:
[DependsOn(
typeof(AbpAspNetCoreSignalRModule)
)]
public class MyWebModule : AbpModule
{
}
You do not need services.AddSignalR() or a manual MapHub<T>(...) — the module
calls AddSignalR() and registers each hub's mapping into AbpEndpointRouterOptions. It
does not call UseEndpoints itself, though: your host's request pipeline must include
app.UseConfiguredEndpoints() (the startup templates already have it), which is where ABP
runs those hub mappings. If that call is missing, no hub endpoints get mapped.
Derive from AbpHub (or AbpHub<TClient> for a strongly-typed client) instead of the
plain Hub / Hub<T>. AbpHub adds useful base members: CurrentUser, CurrentTenant,
Logger, Clock, AuthorizationService, and localization via L.
using Microsoft.AspNetCore.Authorization;
using Volo.Abp;
using Volo.Abp.AspNetCore.SignalR;
[Authorize] // require an authenticated user before any hub method runs
public class MessagingHub : AbpHub
{
// SignalR invokes hub methods by their literal name (it does NOT strip an `Async`
// suffix), so keep the name the client will call.
public async Task SendMessage(Guid targetUserId, string message)
{
Check.NotNullOrWhiteSpace(message, nameof(message)); // validate untrusted input
// A real app should also authorize the recipient (contact/room membership, tenant,
// block lists) — an authenticated user shouldn't be able to message anyone at will.
var senderUserName = CurrentUser.UserName; // current (authenticated) user
Logger.LogInformation("Message from {User}", senderUserName);
// Deliver only to the target user's connections — don't broadcast arbitrary
// user input to everyone with Clients.All.
await Clients.User(targetUserId.ToString())
.SendAsync("ReceiveMessage", senderUserName, message);
}
}
Strongly-typed client variant:
public interface IChatClient
{
Task ReceiveMessage(string user, string message);
}
[Authorize] // the strongly-typed variant needs the same guard as the plain hub
public class ChatHub : AbpHub<IChatClient>
{
public Task SendMessage(string message)
{
Check.NotNullOrWhiteSpace(message, nameof(message)); // validate untrusted input
// Clients.All sends to EVERY connection of this hub — it is NOT a room/group. In a
// shared or multi-tenant host that reaches all users (including other tenants), so
// only broadcast to everyone when that is genuinely intended; for a real chat room,
// scope with Clients.Group(...) / Groups.
return Clients.All.ReceiveMessage(CurrentUser.UserName!, message);
}
}
A plain
Hubalso works with ABP's auto-registration;AbpHubjust gives you the extra base properties without constructor injection.
ABP maps the endpoint conventionally. For a hub named MessagingHub the route is:
/signalr-hubs/messaging
Rule (from HubRouteAttribute.GetRoutePattern): prefix /signalr-hubs/, then the hub
type name with the Hub suffix removed, converted to kebab-case.
Override the route with the HubRoute attribute:
[HubRoute("/my-messaging-hub")]
public class MessagingHub : AbpHub
{
}
Because ABP registers IUserIdProvider (AbpSignalRUserIdProvider) from ICurrentUser,
the hub is integrated with your app's authentication. Protect a hub with the standard
[Authorize] attribute:
using Microsoft.AspNetCore.Authorization;
[Authorize]
public class MessagingHub : AbpHub
{
public async Task SendPrivate(string toUserId, string message)
{
Check.NotNullOrWhiteSpace(message, nameof(message));
// A real app should also authorize the recipient (block lists, contact/room
// membership) — an authenticated user shouldn't be able to message anyone at will.
// Clients.User(...) works because AbpSignalRUserIdProvider maps to ICurrentUser.Id
await Clients.User(toUserId).SendAsync("ReceiveMessage", CurrentUser.UserName, message);
}
}
Inside a hub, CurrentUser reflects the authenticated connection:
CurrentUser.IsAuthenticatedCurrentUser.Id (a Guid?)CurrentUser.UserNameCurrentUser.TenantId (also available via CurrentTenant)For permission checks you can use the base AuthorizationService or an
[Authorize("MyPermission")] policy on the hub/method.
Auto DI registration + auto mapping is the default. To opt out of auto DI registration,
put [DisableConventionalRegistration] on the hub, then register it yourself:
context.Services.AddTransient<MessagingHub>();
To keep DI registration but do the endpoint mapping yourself, add
[DisableAutoHubMap] and configure via AbpSignalROptions:
Configure<AbpSignalROptions>(options =>
{
options.Hubs.Add(
new HubConfig(
typeof(MessagingHub),
"/my-messaging/route",
hubOptions =>
{
hubOptions.LongPolling.PollTimeout = TimeSpan.FromSeconds(30);
}
)
);
});
To tweak a hub defined in a depended module you don't own, use options.Hubs.AddOrUpdate(...)
with a config lambda that sets config.RoutePattern and adds to config.ConfigureActions.
Add the client package and include the script:
abp add-package @abp/signalr # run in the web project root
abp install-libs
Include the script in your page/view (requires
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.SignalR):
@section scripts {
<abp-script type="typeof(SignalRBrowserScriptContributor)" />
}
Then use the standard SignalR JS client:
const connection = new signalR.HubConnectionBuilder()
.withUrl("/signalr-hubs/messaging")
.build();
connection.on("ReceiveMessage", (user, message) => { /* ... */ });
await connection.start();
await connection.invoke("SendMessage", "3fa85f64-5717-4562-b3fc-2c963f66afa6", "Hello");
Use the standard HubConnectionBuilder from Microsoft.AspNetCore.SignalR.Client,
pointing at the conventional route:
var connection = new HubConnectionBuilder()
.WithUrl(NavigationManager.ToAbsoluteUri("/signalr-hubs/messaging"))
.Build();
connection.On<string, string>("ReceiveMessage", (user, message) => { /* ... */ });
await connection.StartAsync();
For an authenticated hub, pass the access token on the client via
options.AccessTokenProvider in WithUrl per the standard Microsoft SignalR client docs.
To send from outside a hub (e.g. an app service), inject
IHubContext<MessagingHub> (standard ASP.NET Core) and call
hubContext.Clients...SendAsync(...).
/signalr-hubs/<kebab-name-without-Hub-suffix>, or the HubRoute override).app.UseConfiguredEndpoints() — without it no hub endpoints are mapped.connection.start() / StartAsync()) and confirm messages round-trip via the registered on/On handler.[Authorize] hub, confirm CurrentUser.IsAuthenticated/CurrentUser.Id reflect the connection and Clients.User(id) delivers to that user.app.UseConfiguredEndpoints(). The module registers hub mappings but does not call UseEndpoints itself — if that pipeline call is absent, no hub endpoints get mapped (startup templates include it).AddSignalR() / MapHub<T>(). The module already does both; hubs are auto-registered (transient) and mapped conventionally.Hub suffix and kebab-cases the name (MessagingHub → /signalr-hubs/messaging); override with [HubRoute].[DisableConventionalRegistration] to skip auto DI (then register yourself), or [DisableAutoHubMap] + AbpSignalROptions to map yourself — they control different things.What SKILL.md sets; muted values are Claude Code's defaults
/abp-realtime:add-signalr-realtimefrom abp-realtime
npx claudepluginhub abpframework/abp-skills --plugin abp-realtimeOther plugins' skills for the same job