Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BlossomiShymae/GrrrLCU
A simple wrapper for the LCU.
https://github.com/BlossomiShymae/GrrrLCU
lcu lcu-api league-of-legends
Last synced: 3 months ago
JSON representation
A simple wrapper for the LCU.
- Host: GitHub
- URL: https://github.com/BlossomiShymae/GrrrLCU
- Owner: BlossomiShymae
- License: mit
- Created: 2024-07-27T05:32:07.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-20T10:55:11.000Z (3 months ago)
- Last Synced: 2024-08-21T03:21:58.201Z (3 months ago)
- Topics: lcu, lcu-api, league-of-legends
- Language: C#
- Homepage:
- Size: 201 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-league - GrrrLCU - A simple C# wrapper for the LCU. (Developer Tools)
README
# GrrrLCU
[![NuGet Stable](https://img.shields.io/nuget/v/BlossomiShymae.GrrrLCU.svg?style=flat-square&logo=nuget&logoColor=black&labelColor=69ffbe&color=77077a)](https://www.nuget.org/packages/BlossomiShymae.GrrrLCU/) [![NuGet Downloads](https://img.shields.io/nuget/dt/BlossomiShymae.GrrrLCU?style=flat-square&logoColor=black&labelColor=69ffbe&color=77077a)](https://www.nuget.org/packages/BlossomiShymae.GrrrLCU/)
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.
## Contributors
## Usage
### Sample application
[A demonstration of GrrrLCU with more code examples can be found here.](https://github.com/BlossomiShymae/GrrrLCU/blob/main/BlossomiShymae.GrrrLCU.Demo/Program.cs)
To run the demo:
```bash
dotnet run --project BlossomiShymae.GrrrLCU.Demo
```### Requesting the LCU
#### General request
```csharp
var response = await Connector.SendAsync(HttpMethod.Get, "/lol-summoner/v1/current-summoner");var me = await response.Content.ReadFromJsonAsync();
```#### GET request
```csharp
var me = await Connector.GetFromJsonAsync("/lol-summoner/v1/current-summoner");
```#### POST request with body
```csharp
var response = await Connector.SendAsync(HttpMethod.Post, "/player-notifications/v1/notifications", new JsonContent(playerNotificationResource));var resource = await response.Content.ReadFromJsonAsync();
```#### Utilities
```csharp
var processInfo = Connector.GetProcessInfo();
var riotAuthentication = new RiotAuthentication(processInfo.RemotingAuthToken);
```### WebSockets
This library uses the `Websocket.Client` wrapper, which comes with built-in reconnection and error handling.
Create a client:
```csharp
var client = Connector.CreateLcuWebsocketClient();
```Listen to events, disconnections, or reconnection messages:
```csharp
using System; // Include to avoid compiler errors CS1503, CS1660
// You may or may not need thisclient.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:
```csharp
// 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(RequestType.Subscribe, EventMessage.Kinds.OnJsonApiEvent);
client.Send(message);// We will need an event loop for the background thread to process.
// You may close at any time with Ctrl+C or similar chord.
while(true) await Task.Delay(TimeSpan.FromSeconds(1));
```