Expand description
§cs2-gsi
Counter-Strike 2 Game State Integration listener for Rust.
- Async, single dependency surface — built on
tokio+hyper1.x. - Strongly typed model and events (no
serde_json::Valuein your code). - Drop-in cfg writer — generate the right
gamestate_integration_*.cfginto the right place via Steam path discovery. - Event diffing done for you: subscribe to
PlayerDied,BombPlanted,RoundPhaseUpdated,KillFeed, … instead of comparing payloads by hand.
§Quick start
use cs2_gsi::{events::PlayerDied, cfg::GsiCfg, GameStateListener};
// 1. Drop a gamestate_integration_*.cfg into the CS2 cfg dir.
#[cfg(feature = "steam-discover")]
GsiCfg::for_localhost("ImLag", 4000).write_to_cs2()?;
// 2. Stand up the listener.
let listener = GameStateListener::new(4000);
listener.on(|e: &PlayerDied| {
println!("☠ {} died", e.player.name);
});
listener.start().await?;
// ... run the rest of your app ...
listener.stop().await?;§How it works
CS2 client Your app
┌──────────┐ ┌───────────────┐
│ cfg file │── HTTP POST JSON ──────────▶│ GameStateList │
└──────────┘ │ (this lib) │
▲ │ diff │
│ generate cfg │ ▼ │
└─────────────────────────────────│ typed events │
└───────────────┘Every payload arrives as JSON, is parsed into a model::GameState,
diffed against the previous one and turned into a stream of typed
events. Handlers run synchronously on the listener task — keep them
light or tokio::spawn from inside.
Re-exports§
pub use crate::error::Error;pub use crate::error::Result;pub use crate::events::GameEvent;pub use crate::model::GameState;
Modules§
- cfg
- Auto-generate
gamestate_integration_*.cfgfiles for Counter-Strike 2. - error
- Error types for cs2-gsi.
- events
- Strongly typed events emitted by
GameStateListener. - model
- Top-level GameState model.
- steam
- Steam / Counter-Strike 2 install path discovery.
Structs§
- Game
State Listener - HTTP listener for CS2 GSI payloads.