Bugfix/small fixes #1
No files matched your search
@@ -67,6 +67,7 @@
|
|||||||
<Separator />
|
<Separator />
|
||||||
<MenuItem Header="Quit" Command="{Binding QuitCommand}" />
|
<MenuItem Header="Quit" Command="{Binding QuitCommand}" />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem Header="Load Game Champs" Command="{Binding UpdateChampionListsFromGameCommand}" />
|
||||||
<MenuItem Header="Reconnect" Command="{Binding ConnectCommand}" Visibility="{Binding ReconnectButtonVisibility, Mode=OneWay}" />
|
<MenuItem Header="Reconnect" Command="{Binding ConnectCommand}" Visibility="{Binding ReconnectButtonVisibility, Mode=OneWay}" />
|
||||||
</Menu>
|
</Menu>
|
||||||
<StatusBar DockPanel.Dock="Bottom">
|
<StatusBar DockPanel.Dock="Bottom">
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ public partial class MainViewModel : ObservableObject, IDisposable
|
|||||||
private readonly LcuWebsocket _lcuWebsocket = new();
|
private readonly LcuWebsocket _lcuWebsocket = new();
|
||||||
private Task _lcuWebsocketTask;
|
private Task _lcuWebsocketTask;
|
||||||
private readonly ARAMBalanceService _aramBalanceService = new();
|
private readonly ARAMBalanceService _aramBalanceService = new();
|
||||||
private readonly ProcessWatcher _leagueWatcher = new();
|
|
||||||
private readonly CachingHttpClient _localCachingClient = new(insecure: true);
|
private readonly CachingHttpClient _localCachingClient = new(insecure: true);
|
||||||
|
|
||||||
public MainViewModel()
|
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");
|
File.AppendAllText("socketerror.log", $"[{DateTime.Now:s}] {e.Message}\n{e.StackTrace}\n\n");
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
_lcuWebsocketTask = _lcuWebsocket.Connect();
|
_lcuWebsocketTask = _lcuWebsocket.ConnectAsync();
|
||||||
|
|
||||||
_leagueWatcher.LeagueOfLegendsExeFound += UpdateChampionListsFromGame;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async void OnInit(object? sender, RoutedEventArgs e)
|
internal async void OnInit(object? sender, RoutedEventArgs e)
|
||||||
@@ -102,6 +99,9 @@ public partial class MainViewModel : ObservableObject, IDisposable
|
|||||||
{
|
{
|
||||||
await FillChampionLists();
|
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)
|
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)
|
switch (apiEvent.Uri)
|
||||||
{
|
{
|
||||||
@@ -140,7 +145,7 @@ public partial class MainViewModel : ObservableObject, IDisposable
|
|||||||
await ShowChampionsAsync(session);
|
await ShowChampionsAsync(session);
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
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));
|
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||||
string playerlistJson = await _localCachingClient.GetStringAsync("https://127.0.0.1:2999/liveclientdata/playerlist", TimeSpan.FromSeconds(30));
|
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)
|
if (_lcuWebsocketTask is null || _lcuWebsocketTask.IsCompleted)
|
||||||
{
|
{
|
||||||
_lcuWebsocketTask?.Dispose();
|
_lcuWebsocketTask?.Dispose();
|
||||||
_lcuWebsocketTask = _lcuWebsocket.Connect();
|
_lcuWebsocketTask = _lcuWebsocket.ConnectAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user