ARAM Utility: update to LeagueAPI changes

added "Load Game Champs"
This commit is contained in:
SacredFloof committed 2026-11-15 12:28:37 +01:00
1 parent d1e7c1b558
commit aafb091e80
2 files changed
+15 -8

No files matched your search

+14 -8
View File
@@ -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();
}
}