signalr-integration
БесплатноБез исполняемых скриптовНе проверенSignalR integration patterns for real-time communication in ASP.NET Core Razor Pages applications. Use when implementing real-time features in ASP.NET Core…
от wshaddix★ 94 звезды на GitHubОб этом скилле
Rationale
Real-time communication enhances user experience with instant updates, notifications, and collaborative features. SignalR provides a robust framework for bidirectional communication between server and clients. Without proper patterns, applications can suffer from connection leaks, scalability issues, and security vulnerabilities. These patterns provide production-ready approaches to SignalR in Razor Pages applications.
Patterns
Pattern 1: Hub Structure and Organization
Organize hubs by domain with proper authentication and group management.
// Base hub with common functionality
public abstract class AuthenticatedHub : Hub
{
protected string? UserId => Context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
protected bool IsAuthenticated => !string.IsNullOrEmpty(UserId);
public override async Task OnConnectedAsync()
{
if (!IsAuthenticated)
{
Context.Abort();
return;
}
await base.OnConnectedAsync();
}
}
// Notification hub for real-time updates
public interface INotificationClient
{
Task ReceiveNotification(NotificationMessage message);
Task NotificationRead(string notificationId);
Task UnreadCountUpdated(int count);
}
public class NotificationHub : AuthenticatedHub<INotificationClient>
{
private readonly INotificationService _notificationService;
private readonly ILogger<NotificationHub> _logger;
public NotificationHub(
INotificationService notificationService,
ILogger<NotificationHub> logger)
{
_notificationService = notificationService;
_logger = logger;
}
public override async Task OnConnectedAsync()
{
await base.OnConnectedAsync();
if (UserId != null)
{
// Join user-specific group
await Groups.AddToGroupAsync(Context.ConnectionId, $"user:{UserId}");
// Send initial unread count
var count = await _notificationService.GetUnreadCountAsync(UserId);
await Clients.Caller.UnreadCountUpdated(count);
_logger.LogDebug("User {UserId} connected to notification hub", UserId);
}
}
public override async Task OnDisconnectedAsync(Exception? exception)
{
if (UserId != null)
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"user:{UserId}");
_logger.LogDebug("User {UserId} disconnected from notification hub", UserId);
}
await base.OnDisconnectedAsync(exception);
}
public async Task MarkAsRead(string notificationId)
{
if (UserId == null) return;
await _notificationService.MarkAsReadAsync(UserId, notificationId);
var count = await _notificationService.GetUnreadCountAsync(UserId);
await Clients.Caller.UnreadCountUpdated(count);
}
public async Task SubscribeToTopic(string topic)
{
// Validate topic access
if (!await CanSubscribeToTopic(topic))
{
throw new HubException("Not authorized for this topic");
}
await Groups.AddToGroupAsync(Context.ConnectionId, $"topic:{topic}");
}
private Task<bool> CanSubscribeToTopic(string topic)
{
// Implement topic authorization logic
return Task.FromResult(true);
}
}
// Order status hub for real-time order updates
public interface IOrderClient
{
Task OrderStatusUpdated(string orderId, OrderStatus status, string? message);
Task OrderProgressUpdated(string orderId, int progressPercent);
Task OrderCompleted(string orderId);
}
public class OrderHub : AuthenticatedHub<IOrderClient>
{
private readonly IOrderService _orderService;
public OrderHub(IOrderService orderService)
{
_orderService = orderService;
}
public async Task SubscribeToOrder(string orderId)
{
if (UserId == null) return;
// Verify user owns this order
var order = await _orderService.GetOrderAsync(orderId);
if (order?.UserId != UserId)
{
throw new HubException("Not authorized to view this order");
}
await Groups.AddToGroupAsync(Context.ConnectionId, $"order:{orderId}");
}
public async Task UnsubscribeFromOrder(string orderId)
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"order:{orderId}");
}
}
Pattern 2: Razor Pages Integration
Integrate SignalR clients in Razor Pages with proper connection lifecycle management.
// SignalR configuration in Program.cs
builder.Services.AddSignalR()
.AddJsonProtocol(options =>
{
options.PayloadSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
})
.AddStackExchangeRedis("redis:6379"); // For scale-out
// Authentication for SignalR
builder.Services.AddAuthentication()
.AddCookie(options =>
{
// Allow SignalR to use cookie auth
Установить signalr-integration в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл signalr-integration?
SignalR integration patterns for real-time communication in ASP.NET Core Razor Pages applications. Use when implementing real-time features in ASP.NET Core applications, setting up SignalR hubs and clients, or managing WebSocket connections and groups.
Как установить скилл signalr-integration?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл signalr-integration запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic