![]() |
VOOZH | about |
Namespace has been renamed.
dotnet add package BlossomiShymae.GrrrLCU --version 0.14.0
NuGet\Install-Package BlossomiShymae.GrrrLCU -Version 0.14.0
<PackageReference Include="BlossomiShymae.GrrrLCU" Version="0.14.0" />
<PackageVersion Include="BlossomiShymae.GrrrLCU" Version="0.14.0" />Directory.Packages.props
<PackageReference Include="BlossomiShymae.GrrrLCU" />Project file
paket add BlossomiShymae.GrrrLCU --version 0.14.0
#r "nuget: BlossomiShymae.GrrrLCU, 0.14.0"
#:package BlossomiShymae.GrrrLCU@0.14.0
#addin nuget:?package=BlossomiShymae.GrrrLCU&version=0.14.0Install as a Cake Addin
#tool nuget:?package=BlossomiShymae.GrrrLCU&version=0.14.0Install as a Cake Tool
👁 NuGet Stable
👁 NuGet Downloads
<img src="./logo.png" width="400">
GrrrLCU is a wrapper for the LCU API which is unofficially provided by Riot Games.
This library is currently compatible with .NET 8 and higher for Windows.
<a href="https://github.com/BlossomiShymae/GrrrLCU/graphs/contributors"> <img src="https://contrib.rocks/image?repo=BlossomiShymae/GrrrLCU" /> </a>
Grrr, GRRR. x3
dotnet install BlossomiShymae.GrrrLCU
A demonstration of GrrrLCU with more code examples can be found here.
To run the demo, clone the repo and then do:
dotnet run --project BlossomiShymae.GrrrLCU.Demo
This library uses the System.Net.Http.HttpClient interface via LcuHttpClient. It comes with a built-in handler that takes care of the request path and authorization header.
The built-in handler will attempt to refresh the port and auth if a HttpRequestException is encountered on request. InvalidOperationException will be thrown if the port of the current LCU process cannot be found or the port cannot be connected to.
var client = Connector.GetLcuHttpClientInstance();
var response = await client.SendAsync(new(HttpMethod.Get, "/lol-summoner/v1/current-summoner"));
var me = await response.Content.ReadFromJsonAsync<Summoner>();
var me = await client.GetFromJsonAsync<Summoner>("/lol-summoner/v1/current-summoner");
var response = await client.PostAsJsonAsync("/player-notifications/v1/notifications", playerNotificationResource);
var resource = await response.Content.ReadFromJsonAsync<PlayerNotificationResource>();
ProcessFinder.IsActive() does not necessarily mean that the LCU process port is open for requests. Use ProcessFinder.IsPortOpen() instead.
var leagueClientProcess = ProcessFinder.GetProcess();
var processInfo = ProcessFinder.GetProcessInfo();
var isActive = ProcessFinder.IsActive();
var isPortOpen = ProcessFinder.IsPortOpen();
var riotAuthentication = new RiotAuthentication(processInfo.RemotingAuthToken);
This library uses the Websocket.Client wrapper.
Create a client:
var client = Connector.CreateLcuWebsocketClient();
Listen to events, disconnections, or reconnection messages:
using System; // Include to avoid compiler errors CS1503, CS1660.
// You may or may not need this.
client.EventReceived.Subscribe(msg =>
{
Console.WriteLine(msg?.Data?.Uri);
});
client.DisconnectionHappened.Subscribe(msg =>
{
if (msg.Exception != null) throw msg.Exception;
});
client.ReconnectionHappened.Subscribe(msg =>
{
Console.WriteLine(msg.Type);
});
Use it:
// This starts the client in a background thread. You will need an event loop
// to listen to messages.
await client.Start();
// Subscribe to every event that the League Client sends.
var message = new EventMessage(EventRequestType.Subscribe, EventKinds.OnJsonApiEvent);
client.Send(message);
// We will need an event loop for the background thread to process.
while(true) await Task.Delay(TimeSpan.FromSeconds(1));
Whenever a public application is made with GrrrLCU, graceful reconnection is needed as the end-user may restart, exit, or open the League client. The built-in reconnection handler will not be enough for this case.
An example pattern using threads is provided to show how reconnection can be done.
public class ExampleViewModel
{
public WebsocketClient? Client { get; set; }
public ExampleViewModel()
{
new Thread(InitializeWebsocket) { IsBackground = true }.Start();
}
private void InitializeWebsocket()
{
while (true)
{
try
{
var client = Connector.CreateLcuWebsocketClient();
client.DisconnectionHappened.Subscribe(OnDisconnection);
client.Start();
client.Send(new EventMessage(EventRequestType.Subscribe, EventKinds.OnJsonApiEvent));
Client = client;
return;
}
catch (Exception) { }
Thread.Sleep(TimeSpan.FromSeconds(5));
}
}
private void OnDisconnection(DisconnectionInfo info)
{
Client?.Dispose();
new Thread(InitializeWebsocket) { IsBackground = true }.Start();
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 net8.0-windows7.0 is compatible. net9.0-windows net9.0-windows was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 0.14.0 | 414 | 8/29/2024 | 0.14.0 is deprecated because it is no longer maintained. |
| 0.13.1 | 237 | 8/24/2024 | |
| 0.13.0 | 235 | 8/23/2024 | |
| 0.12.0 | 245 | 8/22/2024 | |
| 0.11.1 | 257 | 8/20/2024 | |
| 0.11.0 | 260 | 8/20/2024 | |
| 0.10.0 | 271 | 8/16/2024 | |
| 0.9.0 | 253 | 8/10/2024 | |
| 0.8.0 | 240 | 8/8/2024 | |
| 0.7.0 | 225 | 8/7/2024 | |
| 0.6.0 | 198 | 8/7/2024 | |
| 0.5.0 | 201 | 8/4/2024 | |
| 0.4.0 | 182 | 8/2/2024 | |
| 0.3.0 | 183 | 8/1/2024 | |
| 0.2.0 | 144 | 7/31/2024 | |
| 0.1.1 | 196 | 7/27/2024 | |
| 0.1.0 | 185 | 7/27/2024 |