@using DiscordBotWebUI.ServerCommunication.Sockets
@inject DialogService DialogService

<RadzenProgressBar Value="progressValue" ShowValue="false"/>

@code {
    private float progressValue = 0f;
    
    [Parameter]
    public string ProgressUrl { get; set; }
    
    [Parameter]
    public string FirstMessage { get; set; }

    protected override async Task OnInitializedAsync()
    {
        
        WebSocketClientService service = new WebSocketClientService();
        await service.ConnectAsync(ProgressUrl);
        await Task.Delay(1000);
        await service.SendMessageAsync(FirstMessage);
        service.OnMessageReceived += (msg) =>
        {
            progressValue = float.Parse(msg);
            StateHasChanged();
        };
        await service.ReceiveMessages();
        await Task.Delay(500);
        DialogService.Close();
    }

}
