From aafb091e80f1cd839096d1b0dfb7a96f62e20f08 Mon Sep 17 00:00:00 2001 From: SacredFloof Date: Sun, 15 Nov 2026 12:28:37 +0100 Subject: [PATCH] ARAM Utility: update to LeagueAPI changes added "Load Game Champs" --- ARAMUtility/View/MainWindow.xaml | 1 + ARAMUtility/ViewModel/MainViewModel.cs | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ARAMUtility/View/MainWindow.xaml b/ARAMUtility/View/MainWindow.xaml index e1d7d6d..5157330 100644 --- a/ARAMUtility/View/MainWindow.xaml +++ b/ARAMUtility/View/MainWindow.xaml @@ -67,6 +67,7 @@ + diff --git a/ARAMUtility/ViewModel/MainViewModel.cs b/ARAMUtility/ViewModel/MainViewModel.cs index d563ecc..5247101 100644 --- a/ARAMUtility/ViewModel/MainViewModel.cs +++ b/ARAMUtility/ViewModel/MainViewModel.cs @@ -58,7 +58,6 @@ public partial class MainViewModel : ObservableObject, IDisposable private readonly LcuWebsocket _lcuWebsocket = new(); private Task _lcuWebsocketTask; private readonly ARAMBalanceService _aramBalanceService = new(); - private readonly ProcessWatcher _leagueWatcher = new(); private readonly CachingHttpClient _localCachingClient = new(insecure: true); public MainViewModel() @@ -74,9 +73,7 @@ public partial class MainViewModel : ObservableObject, IDisposable File.AppendAllText("socketerror.log", $"[{DateTime.Now:s}] {e.Message}\n{e.StackTrace}\n\n"); }; #endif - _lcuWebsocketTask = _lcuWebsocket.Connect(); - - _leagueWatcher.LeagueOfLegendsExeFound += UpdateChampionListsFromGame; + _lcuWebsocketTask = _lcuWebsocket.ConnectAsync(); } internal async void OnInit(object? sender, RoutedEventArgs e) @@ -102,6 +99,9 @@ public partial class MainViewModel : ObservableObject, IDisposable { await FillChampionLists(); } + + await _lcuWebsocket.SubscribeAsync("/lol-matchmaking/v1/ready-check".GetLcuEventName()); + await _lcuWebsocket.SubscribeAsync("/lol-champ-select/v1/session".GetLcuEventName()); } private void UpdateConnectionStatus(bool isConnected, ConnectionStatus status) @@ -113,7 +113,12 @@ public partial class MainViewModel : ObservableObject, IDisposable }); } - private async void OnLcuApiEvent(object? sender, LcuApiEvent apiEvent) + private void OnLcuApiEvent(object? sender, LcuApiEvent apiEvent) + { + _ = ProcessLcuApiEvent(apiEvent); + } + + private async Task ProcessLcuApiEvent(LcuApiEvent apiEvent) { switch (apiEvent.Uri) { @@ -140,7 +145,7 @@ public partial class MainViewModel : ObservableObject, IDisposable await ShowChampionsAsync(session); break; default: - File.AppendAllText("socket.log", $"{apiEvent.Uri}: {apiEvent.EventType} - {apiEvent.Data?.ToJsonString()}\n"); + File.AppendAllText("socket.log", $"{apiEvent.Uri}: {apiEvent.EventType} - {apiEvent.Data.GetRawText()}\n"); break; } } @@ -232,7 +237,8 @@ public partial class MainViewModel : ObservableObject, IDisposable } } - private async void UpdateChampionListsFromGame(object? sender, EventArgs e) + [RelayCommand(AllowConcurrentExecutions = false)] + private async Task UpdateChampionListsFromGame() { await Task.Delay(TimeSpan.FromSeconds(5)); string playerlistJson = await _localCachingClient.GetStringAsync("https://127.0.0.1:2999/liveclientdata/playerlist", TimeSpan.FromSeconds(30)); @@ -270,7 +276,7 @@ public partial class MainViewModel : ObservableObject, IDisposable if (_lcuWebsocketTask is null || _lcuWebsocketTask.IsCompleted) { _lcuWebsocketTask?.Dispose(); - _lcuWebsocketTask = _lcuWebsocket.Connect(); + _lcuWebsocketTask = _lcuWebsocket.ConnectAsync(); } }