about summary refs log tree commit diff
path: root/MatrixUtils.Web/Pages/HSEInit.razor
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-02-23 11:26:00 +0000
committerRory& <root@rory.gay>2024-02-23 11:26:00 +0000
commite12117061631523aa136ff81638abdeb1fb23997 (patch)
treea04688939c6717b4b2e66cadd2939aa0de10f638 /MatrixUtils.Web/Pages/HSEInit.razor
parentNew tools, fix room list items (diff)
downloadMatrixUtils-e12117061631523aa136ff81638abdeb1fb23997.tar.xz
HS emulator
Diffstat (limited to 'MatrixUtils.Web/Pages/HSEInit.razor')
-rw-r--r--MatrixUtils.Web/Pages/HSEInit.razor37
1 files changed, 37 insertions, 0 deletions
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
+<h3>HSE Initialising...</h3>
+<hr/>
+@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<UserAuth?> 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