chore: extract the ship into multiple files (#172)

* chore: extract the ship into multiple files

* fix: actual the ship reference link

* fix: revert last commit and replace in ts
This commit is contained in:
CosminPerRam 2023-12-19 20:58:15 +01:00 committed by GitHub
parent 99b0269ec2
commit bdcf64facf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 29 deletions

View file

@ -0,0 +1,23 @@
use crate::games::theship::types::Response;
use crate::protocols::types::TimeoutSettings;
use crate::protocols::valve;
use crate::protocols::valve::Engine;
use crate::GDResult;
use std::net::{IpAddr, SocketAddr};
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)),
Engine::new(2400),
None,
timeout_settings,
)?;
Response::new_from_valve_response(valve_response)
}