From e12117061631523aa136ff81638abdeb1fb23997 Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 23 Feb 2024 11:26:00 +0000 Subject: HS emulator --- MatrixUtils.Web/Pages/HSEInit.razor | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 MatrixUtils.Web/Pages/HSEInit.razor (limited to 'MatrixUtils.Web/Pages/HSEInit.razor') diff --git a/MatrixUtils.Web/Pages/HSEInit.razor b/MatrixUtils.Web/Pages/HSEInit.razor new file mode 100644 index 0000000..3020ff7 --- /dev/null +++ b/MatrixUtils.Web/Pages/HSEInit.razor @@ -0,0 +1,37 @@ +@page "/HSEInit" +@inject ILocalStorageService LocalStorage +@inject IJSRuntime JsRuntime +

HSE Initialising...

+
+@code { + protected override async Task OnInitializedAsync() { + await base.OnInitializedAsync(); + var tasks = Enumerable.Range(0, 5000).Select(i => Login()).ToList(); + await Task.WhenAll(tasks); + Console.WriteLine("All logins complete!"); + var userAuths = tasks.Select(t => t.Result).Where(t => t != null).ToList(); + await LocalStorage.SetItemAsync("rmu.tokens", userAuths); + NavigationManager.NavigateTo("/", true); + } + + async Task Login() { + try { + var result = new UserAuth(await hsProvider.Login("http://localhost:5298", "", "")); + if (result == null) { + Console.WriteLine($"Failed to login!"); + return null; + } + + Console.WriteLine($"Obtained access token for {result.UserId}!"); + + return result; + } + catch (Exception e) { + // Console.WriteLine($"Failed to login to {record.Homeserver} as {record.Username}!"); + Console.WriteLine(e); + // record.Exception = e; + } + + return null; + } +} \ No newline at end of file -- cgit 1.4.1