@inject ServerProcessService ServerProcessService
@inject NotificationService NotificationService
@ChildContent
@code {
[Parameter] public RenderFragment ChildContent { get; set; }
Dictionary CurrentServerStatus = new();
protected override async Task OnInitializedAsync()
{
ServerProcessService.OnStatusUpdate += ServerProcessServiceOnOnStatusUpdate;
}
private void ServerProcessServiceOnOnStatusUpdate(object? sender, ServerStatusUpdateEventArgs e)
{
if (!CurrentServerStatus.ContainsKey(e.Server.Id))
CurrentServerStatus[e.Server.Id] = e.Status;
else if (CurrentServerStatus[e.Server.Id] != e.Status)
CurrentServerStatus[e.Server.Id] = e.Status;
if (e.Status == ServerProcessStatus.Error)
{
NotificationService.Error(new NotificationConfig
{
Message = $"Error starting server {e.Server.Name}",
Description = e.Exception.Message,
});
}
}
}