plugins/dotnet-blazor/skills/signalr-realtime/SKILL.md
SignalR for real-time communication in Blazor apps including hubs, groups, streaming, and scaling
npx skillsauth add markus41/claude signalr-realtimeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
public sealed class NotificationHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
public async Task JoinGroup(string groupName)
{
await Groups.AddToGroupAsync(Context.ConnectionId, groupName);
await Clients.Group(groupName).SendAsync("UserJoined", Context.UserIdentifier);
}
public async Task SendToGroup(string groupName, string message)
{
await Clients.Group(groupName).SendAsync("ReceiveMessage", message);
}
public override async Task OnConnectedAsync()
{
await base.OnConnectedAsync();
// Track connection
}
}
builder.Services.AddSignalR()
.AddJsonProtocol(options =>
{
options.PayloadSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
});
app.MapHub<NotificationHub>("/hubs/notifications");
Blazor Server already uses SignalR for its circuit. For additional hubs:
@rendermode InteractiveServer
@inject NavigationManager Navigation
@implements IAsyncDisposable
@code {
private HubConnection? _hub;
protected override async Task OnInitializedAsync()
{
_hub = new HubConnectionBuilder()
.WithUrl(Navigation.ToAbsoluteUri("/hubs/notifications"))
.WithAutomaticReconnect()
.Build();
_hub.On<string, string>("ReceiveMessage", (user, message) =>
{
_messages.Add(new(user, message));
InvokeAsync(StateHasChanged);
});
await _hub.StartAsync();
}
public async ValueTask DisposeAsync()
{
if (_hub is not null)
await _hub.DisposeAsync();
}
}
public interface INotificationClient
{
Task ReceiveMessage(string user, string message);
Task UserJoined(string userId);
Task OrderUpdated(OrderStatusDto status);
}
public sealed class NotificationHub : Hub<INotificationClient>
{
public async Task SendMessage(string user, string message)
{
await Clients.All.ReceiveMessage(user, message);
}
}
public sealed class OrderService(IHubContext<NotificationHub, INotificationClient> hub)
{
public async Task UpdateStatusAsync(int orderId, string status)
{
// Update DB...
await hub.Clients.Group($"order-{orderId}")
.OrderUpdated(new OrderStatusDto(orderId, status));
}
}
builder.Services.AddSignalR()
.AddStackExchangeRedis(builder.Configuration.GetConnectionString("Redis")!);
public class ChatHub : Hub
{
// Broadcast to ALL connected clients
await Clients.All.SendAsync("ReceiveMessage", user, message);
// Send to specific client by connection ID
await Clients.Client(targetConnectionId).SendAsync("ReceivePrivateMessage", message);
// Send to all EXCEPT caller
await Clients.Others.SendAsync("ReceiveMessage", message);
// Group operations
await Groups.AddToGroupAsync(Context.ConnectionId, groupName);
await Clients.Group(groupName).SendAsync("ReceiveGroupMessage", message);
await Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
// Send to group except caller
await Clients.GroupExcept(groupName, Context.ConnectionId)
.SendAsync("ReceiveMessage", message);
}
const connection = new signalR.HubConnectionBuilder()
.withUrl("/chatHub")
.withAutomaticReconnect()
.build();
// Server calls this method on client
connection.on("ReceiveMessage", (user, message) => {
document.getElementById("messages").innerHTML += `<li>${user}: ${message}</li>`;
});
// Client calls server method
await connection.invoke("SendMessage", user, message);
// Connection lifecycle
connection.onreconnecting((error) => console.log("Reconnecting..."));
connection.onreconnected((connectionId) => console.log("Reconnected:", connectionId));
connection.onclose((error) => console.log("Connection closed"));
connection.start().catch(err => console.error(err));
SignalR automatically negotiates the best transport:
tools
Build Teams-native agents with the Teams SDK (formerly Teams AI Library v2) — App class, activity routing, adaptive cards, streaming, AI-generated labels, feedback, message extensions, Teams-as-MCP-server, and the bring-your-own-AI pattern with Agent Framework.
tools
Run agents on Microsoft Foundry (formerly Azure AI Foundry) Agent Service — prompt agents vs hosted agents, threads/runs and the Responses API, built-in tools (Bing grounding, code interpreter, file search, MCP, OpenAPI, A2A), connected agents, Entra agent identity, SDKs, and observability/evaluations.
tools
Build and host custom engine agents with the Microsoft 365 Agents SDK — AgentApplication, the Activity protocol, channel reach via Azure Bot Service, hosting Agent Framework or Semantic Kernel engines, and the Agents Toolkit/Playground workflow. Successor to the Bot Framework SDK.
tools
Design, govern, and extend Microsoft Copilot Studio agents — topics, generative orchestration, knowledge, tools and MCP, agent flows, autonomous triggers, publishing channels, Copilot Credits pricing, and solution-based ALM on Power Platform.