Files
IT_Tool/Backend/src/NexusRMM.Api/Hubs/RmmHub.cs
Claude Agent d17df20f5e feat: implement Phase 4 — SignalR real-time updates
Backend:
- RmmHub with typed IRmmHubClient interface (AgentMetricsUpdated, AgentStatusChanged, CommandResultUpdated)
- JoinAgentGroup / LeaveAgentGroup for per-agent subscriptions
- AgentGrpcService now pushes to SignalR after every Heartbeat and CommandResult
- Program.cs maps /hubs/rmm

Frontend:
- useSignalR hook with exponential backoff reconnect (0s/2s/10s/30s)
- useGlobalSignalR: invalidates agents query on AgentStatusChanged
- useAgentSignalR: joins agent group, invalidates metrics/tasks on updates
- DashboardPage: live agent status updates via SignalR
- AgentDetailPage: live metrics/command results + connection status indicator

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 13:53:40 +01:00

39 lines
1.2 KiB
C#

using Microsoft.AspNetCore.SignalR;
namespace NexusRMM.Api.Hubs;
public class RmmHub : Hub<IRmmHubClient>
{
private readonly ILogger<RmmHub> _logger;
public RmmHub(ILogger<RmmHub> logger)
{
_logger = logger;
}
/// <summary>Frontend tritt der Gruppe für einen bestimmten Agent bei</summary>
public async Task JoinAgentGroup(string agentId)
{
await Groups.AddToGroupAsync(Context.ConnectionId, $"agent-{agentId}");
_logger.LogDebug("Client {ConnectionId} joined group agent-{AgentId}", Context.ConnectionId, agentId);
}
/// <summary>Frontend verlässt die Gruppe für einen Agent</summary>
public async Task LeaveAgentGroup(string agentId)
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"agent-{agentId}");
}
public override async Task OnConnectedAsync()
{
_logger.LogInformation("SignalR client connected: {ConnectionId}", Context.ConnectionId);
await base.OnConnectedAsync();
}
public override async Task OnDisconnectedAsync(Exception? exception)
{
_logger.LogInformation("SignalR client disconnected: {ConnectionId}", Context.ConnectionId);
await base.OnDisconnectedAsync(exception);
}
}