mirror of
https://github.com/Tribufu/rust-gamedig
synced 2026-08-19 03:41:05 +00:00
[Games] Add timeout settings for proprietary games (#67)
Adding query functions with timeout settings to proprietary games allows the generic query with timeout function to pass the timeout settings through. This does change how the pre-existing FFOW query_with_timeout function worked: it accepted a non-optional timeout settings, this was changed to optional to be consistent with other query_with_timeout functions and to move deciding what to do if the user doesn't provide timeout settings to a more central location. Closes #64
This commit is contained in:
parent
f3a792e325
commit
e207e8dc95
4 changed files with 28 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
protocols::{
|
||||
types::{CommonPlayer, CommonResponse, GenericPlayer},
|
||||
types::{CommonPlayer, CommonResponse, GenericPlayer, TimeoutSettings},
|
||||
valve::{self, get_optional_extracted_data, Server, ServerPlayer, SteamApp},
|
||||
GenericResponse,
|
||||
},
|
||||
|
|
@ -126,12 +126,18 @@ impl Response {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> {
|
||||
pub fn query(address: &IpAddr, port: Option<u16>) -> GDResult<Response> { query_with_timeout(address, port, None) }
|
||||
|
||||
pub fn query_with_timeout(
|
||||
address: &IpAddr,
|
||||
port: Option<u16>,
|
||||
timeout_settings: Option<TimeoutSettings>,
|
||||
) -> GDResult<Response> {
|
||||
let valve_response = valve::query(
|
||||
&SocketAddr::new(*address, port.unwrap_or(27015)),
|
||||
SteamApp::TS.as_engine(),
|
||||
None,
|
||||
None,
|
||||
timeout_settings,
|
||||
)?;
|
||||
|
||||
Ok(Response::new_from_valve_response(valve_response))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue