lighty-event

Real-time event system for monitoring launcher operations and progress tracking.

Overview

lighty-event provides a publish-subscribe event system for:

  • Real-time Progress Tracking - Download, install, and extraction progress

  • Lifecycle Monitoring - Authentication, launch, and instance management

  • Console Streaming - Live game console output (stdout/stderr)

  • Multi-Subscriber Support - Broadcast to UI, logs, and analytics simultaneously

Quick Start

[dependencies]
lighty-event = "0.8.6"
use lighty_event::{EventBus, Event};

#[tokio::main]
async fn main() {
    // Create event bus
    let event_bus = EventBus::new(1000);
    let mut receiver = event_bus.subscribe();

    // Spawn event listener
    tokio::spawn(async move {
        while let Ok(event) = receiver.next().await {
            match event {
                Event::DownloadProgress(e) => {
                    let percent = (e.current * 100) / e.total;
                    println!("Download: {}%", percent);
                }
                Event::InstanceLaunched(e) => {
                    println!("Game launched: {} (PID: {})", e.instance_name, e.pid);
                }
                Event::ConsoleOutput(e) => {
                    print!("[{}] {}", e.stream, e.line);
                }
                _ => {}
            }
        }
    });

    // Use event_bus with launcher operations
    // auth.authenticate(Some(&event_bus)).await.unwrap();
    // version.launch(&profile, java).with_event_bus(&event_bus).run().await.unwrap();
}

Event Categories

Category
Description
Key Events

AuthEvent

Authentication flow

AuthenticationStarted, AuthenticationSuccess, AuthenticationFailed

JavaEvent

JRE management

JavaDownloadProgress, JavaExtractionProgress, JavaAlreadyInstalled

LaunchEvent

Game lifecycle

InstallStarted, InstallProgress, Launched, ProcessExited

LoaderEvent

Mod loaders

FetchingData, DataFetched, ManifestCached, MergingLoaderData

CoreEvent

System operations

DownloadStarted, ExtractionProgress, VerificationCompleted

InstanceEvent

Instance management

InstanceLaunched, ConsoleOutput, InstanceExited, InstanceDeleted

Documentation

📚 Complete Documentationarrow-up-right

Guide
Description

Event bus design and data flow

Complete event catalog

Event module organization

Practical usage patterns

License

MIT

Last updated