Bugfix/small fixes #1

Merged
SacredFloof merged 5 commits from bugfix/small-fixes into main 2026-11-15 11:29:28 +00:00
2 changed files with 15 additions and 8 deletions
Showing only changes of commit aafb091e80 - Show all commits

No files matched your search

+1
View File
@@ -67,6 +67,7 @@
<Separator />
<MenuItem Header="Quit" Command="{Binding QuitCommand}" />
</MenuItem>
<MenuItem Header="Load Game Champs" Command="{Binding UpdateChampionListsFromGameCommand}" />
<MenuItem Header="Reconnect" Command="{Binding ConnectCommand}" Visibility="{Binding ReconnectButtonVisibility, Mode=OneWay}" />
</Menu>
<StatusBar DockPanel.Dock="Bottom">
+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();
}
}