Initial commit: JDE Scoping Tool migration project
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
using JdeScoping.Core.Models;
|
||||
using JdeScoping.Core.Models.Infrastructure;
|
||||
using JdeScoping.Core.Models.Search;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JdeScoping.Api.Hubs;
|
||||
|
||||
/// <summary>
|
||||
/// SignalR hub for real-time status updates
|
||||
/// </summary>
|
||||
public class StatusHub : Hub
|
||||
{
|
||||
private static StatusUpdate _cachedStatus = new()
|
||||
{
|
||||
Message = "Unknown",
|
||||
Timestamp = DateTime.UtcNow
|
||||
};
|
||||
|
||||
private readonly ILogger<StatusHub> _logger;
|
||||
|
||||
public StatusHub(ILogger<StatusHub> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by worker service to update status.
|
||||
/// Caches the update and broadcasts to all clients.
|
||||
/// </summary>
|
||||
/// <param name="statusUpdate">Status update to broadcast</param>
|
||||
public async Task SetStatus(StatusUpdate statusUpdate)
|
||||
{
|
||||
_cachedStatus = statusUpdate;
|
||||
await Clients.All.SendAsync("statusUpdate", statusUpdate);
|
||||
_logger.LogDebug("Status updated: {Message}", statusUpdate.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by clients to get initial cached status on connection.
|
||||
/// </summary>
|
||||
/// <returns>The most recent status update</returns>
|
||||
public StatusUpdate GetCachedStatus()
|
||||
{
|
||||
return _cachedStatus;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by controllers/services to broadcast search updates.
|
||||
/// </summary>
|
||||
/// <param name="searchUpdate">Search update to broadcast</param>
|
||||
public async Task PublishSearchUpdate(SearchUpdate searchUpdate)
|
||||
{
|
||||
await Clients.All.SendAsync("searchUpdate", searchUpdate);
|
||||
_logger.LogDebug("Search update published: ID={Id}, Status={Status}", searchUpdate.Id, searchUpdate.Status);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task OnConnectedAsync()
|
||||
{
|
||||
_logger.LogInformation("Client {ConnectionId} connected to StatusHub", Context.ConnectionId);
|
||||
return base.OnConnectedAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task OnDisconnectedAsync(Exception? exception)
|
||||
{
|
||||
_logger.LogInformation("Client {ConnectionId} disconnected from StatusHub", Context.ConnectionId);
|
||||
return base.OnDisconnectedAsync(exception);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user