HS emulator
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
|