34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using FinlyticCore.Models.Auth;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace FinlyticBackend.Hubs;
|
|
|
|
/// <summary>
|
|
/// Real-time SignalR WebSocket & Server-Sent Events (SSE) Hub streaming live trade proposals & updates to Web and Mobile clients.
|
|
/// </summary>
|
|
public class TradeRealtimeHub : Hub<ITradeClient>
|
|
{
|
|
private readonly ILogger<TradeRealtimeHub> _logger;
|
|
|
|
public TradeRealtimeHub(ILogger<TradeRealtimeHub> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public override async Task OnConnectedAsync()
|
|
{
|
|
_logger.LogInformation("Real-time SignalR Client connected: ConnectionId={ConnectionId}, User={User}",
|
|
Context.ConnectionId, Context.User?.Identity?.Name ?? "Anonymous");
|
|
await base.OnConnectedAsync();
|
|
}
|
|
|
|
public override async Task OnDisconnectedAsync(Exception? exception)
|
|
{
|
|
_logger.LogInformation("Real-time SignalR Client disconnected: ConnectionId={ConnectionId}", Context.ConnectionId);
|
|
await base.OnDisconnectedAsync(exception);
|
|
}
|
|
}
|