@using Microsoft.AspNetCore.SignalR.Client @using Microsoft.Extensions.DependencyInjection @inject NavigationManager Navigation @inject ToastService ToastService @implements IAsyncDisposable

SignalR

SignalR is used by Moonlight to provide realtime communication to itself and other modules. You can test the SignalR communication by pressing the button below. For scaled instances you need to configure a redis compatible server to be used by all your replicas in order for all SignalR Hubs to be synced.

Send broadcast
@code { private HubConnection? Connection; private async Task LoadAsync(LazyLoader lazyLoader) { await lazyLoader.UpdateTextAsync("Connecting to SignalR endpoint"); Connection = new HubConnectionBuilder() .WithUrl(Navigation.ToAbsoluteUri("/api/admin/system/diagnose/ws")) .AddJsonProtocol() .Build(); Connection.On( "Pong", async () => await ToastService.SuccessAsync("Received broadcast") ); await Connection.StartAsync(); } private async Task OnClick(WButton _) { if (Connection == null) return; await Connection.SendAsync("Ping"); } public async ValueTask DisposeAsync() { if (Connection != null) await Connection.DisposeAsync(); } }