using Microsoft.AspNetCore.SignalR;

namespace Managing.Application.Hubs;

public class BacktestHub : Hub
{
    public override async Task OnConnectedAsync()
    {
        await base.OnConnectedAsync();
        await Clients.Caller.SendAsync("Message", "Connected to BacktestHub!");
    }

    public async Task SubscribeToBundle(string requestId)
    {
        if (!string.IsNullOrWhiteSpace(requestId))
        {
            await Groups.AddToGroupAsync(Context.ConnectionId, $"bundle-{requestId}");
            await Clients.Caller.SendAsync("SubscribedToBundle", requestId);
        }
    }

    public string GetConnectionId() => Context.ConnectionId;
}
