mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
Merge branch 'main' into feat/cli
This commit is contained in:
commit
963040fb84
28 changed files with 1071 additions and 348 deletions
28
crates/lib/examples/valve_protocol_query.rs
Normal file
28
crates/lib/examples/valve_protocol_query.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
use gamedig::protocols::types::TimeoutSettings;
|
||||
use gamedig::protocols::valve;
|
||||
use gamedig::protocols::valve::{Engine, GatheringSettings};
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
let address = &SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 27015);
|
||||
let engine = Engine::Source(None); // We don't specify a steam app id, let the query try to find it.
|
||||
let gather_settings = GatheringSettings {
|
||||
players: true, // We want to query for players
|
||||
rules: false, // We don't want to query for rules
|
||||
check_app_id: false, // Loosen up the query a bit by not checking app id
|
||||
};
|
||||
|
||||
let read_timeout = Duration::from_secs(2);
|
||||
let write_timeout = Duration::from_secs(3);
|
||||
let retries = 1; // does another request if the first one fails.
|
||||
let timeout_settings = TimeoutSettings::new(Some(read_timeout), Some(write_timeout), retries).unwrap();
|
||||
|
||||
let response = valve::query(
|
||||
address,
|
||||
engine,
|
||||
Some(gather_settings),
|
||||
Some(timeout_settings),
|
||||
);
|
||||
println!("{response:#?}");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue