Search Results for

    Show / Hide Table of Contents

    Quickstart

    This guide walks through package selection, DI registration, first HTTP call, and event subscription.

    1) Choose packages

    Start with Thresh.Extensions.

    Add optional packages only when needed:

    • Thresh.Endpoints for typed endpoint groups
    • Thresh.Hosting for hosted/background process integration
    • Thresh.HealthChecks for readiness/liveness checks
    • Thresh.Reactive for reactive composition

    For detailed guidance, see Package guidance.

    2) Install

    dotnet add package Thresh.Extensions
    

    3) Register services

    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Logging;
    using Thresh.Abstractions;
    using Thresh.Extensions;
    
    var services = new ServiceCollection()
        .AddLogging(b => b.AddSimpleConsole())
        .AddThresh(o =>
        {
            o.AcceptSelfSignedCertificates = true;    // LCU HTTP (loopback only)
            o.WsAcceptSelfSignedCertificates = true;  // LCU WebSocket (loopback only)
        });
    
    await using var provider = services.BuildServiceProvider();
    

    4) Resolve clients

    var api = provider.GetRequiredService<ILcuHttpClient>();
    var ws = provider.GetRequiredService<IEventStream>();
    

    5) Connect the event stream

    await ws.ConnectAsync();
    var connected = await ws.WaitUntilConnectedAsync(TimeSpan.FromSeconds(3));
    if (!connected)
    {
        Console.WriteLine("WebSocket connection timeout.");
    }
    

    6) Subscribe to typed events (with snapshot)

    using var sub = ws.Subscribe<System.Text.Json.JsonElement>("/lol-gameflow/v1/session", data =>
    {
        var phase = data.TryGetProperty("phase", out var p) ? p.GetString() : "?";
        Console.WriteLine($"Gameflow phase = {phase}");
    }, withSnapshot: true);
    

    7) Perform a REST call

    var me = await api.GetAsync<System.Text.Json.JsonElement>("/lol-summoner/v1/current-summoner");
    Console.WriteLine(me?.GetProperty("displayName").GetString());
    

    Prerequisites

    • Official runtime support is Windows and macOS.
    • Other environments (including Linux/Wine/Proton variants) are best-effort.
    • League Client must be running, or LCU_LOCKFILE must point to a valid lockfile path.

    Lockfile discovery order:

    1. LCU_LOCKFILE environment override
    2. cached lockfile path (if valid)
    3. process-derived candidates
    4. known install paths per platform

    Notes

    • IEventStream implements IAsyncDisposable; prefer await using where relevant.
    • For local development, self-signed certificate options remain loopback scoped.
    • Prefer relative LCU paths to use lockfile-derived rebasing and safe auth destination checks.

    Build local docs (DocFX)

    dotnet tool update -g docfx
    docfx docs/docfx.json --serve
    

    Open http://localhost:8080.

    The docs.yml workflow publishes docs/_site to GitHub Pages.

    • Edit this page
    In this article
    Back to top Generated by DocFX