pub struct GnsUtils(/* private fields */);Implementations§
Source§impl GnsUtils
impl GnsUtils
Sourcepub fn enable_debug_output(
&self,
ty: ESteamNetworkingSocketsDebugOutputType,
f: impl Fn(ESteamNetworkingSocketsDebugOutputType, &str) + Send + Sync + 'static,
)
pub fn enable_debug_output( &self, ty: ESteamNetworkingSocketsDebugOutputType, f: impl Fn(ESteamNetworkingSocketsDebugOutputType, &str) + Send + Sync + 'static, )
Installs a debug callback.
Only the first call takes effect. Later calls are ignored.
GameNetworkingSockets runs the callback on its service thread, which is
why the callback must be Send + Sync + 'static. The callback may
capture state, because the wrapper stores it as a boxed closure. The
&str is borrowed only for the duration of the call.
Sourcepub fn allocate_message<P: Payload>(
&self,
conn: GnsConnection,
flags: SendFlags,
payload: P,
) -> GnsNetworkMessage<ToSend>
pub fn allocate_message<P: Payload>( &self, conn: GnsConnection, flags: SendFlags, payload: P, ) -> GnsNetworkMessage<ToSend>
Allocates an outbound message and takes ownership of payload.
The buffer stays alive until GameNetworkingSockets releases the message.
At that point the wrapper rebuilds P with Payload::from_raw and
drops it. Nothing is copied when the payload already owns heap memory.
Sourcepub fn set_global_config_value(
&self,
typ: ESteamNetworkingConfigValue,
value: GnsConfig<'_>,
) -> GnsResult<()>
pub fn set_global_config_value( &self, typ: ESteamNetworkingConfigValue, value: GnsConfig<'_>, ) -> GnsResult<()>
Sets a global configuration value, for example
k_ESteamNetworkingConfig_FakePacketLag_Send to 1000 ms.
Sourcepub fn set_connection_config_value(
&self,
conn: GnsConnection,
typ: ESteamNetworkingConfigValue,
value: GnsConfig<'_>,
) -> GnsResult<()>
pub fn set_connection_config_value( &self, conn: GnsConnection, typ: ESteamNetworkingConfigValue, value: GnsConfig<'_>, ) -> GnsResult<()>
Sets a configuration value on one connection, for example
k_ESteamNetworkingConfig_SendRateMin on an accepted connection.
Sourcepub fn get_global_config_value(
&self,
typ: ESteamNetworkingConfigValue,
) -> GnsResult<GnsConfigValue>
pub fn get_global_config_value( &self, typ: ESteamNetworkingConfigValue, ) -> GnsResult<GnsConfigValue>
Reads a global configuration value back, the counterpart of
Self::set_global_config_value.
Sourcepub fn get_connection_config_value(
&self,
conn: GnsConnection,
typ: ESteamNetworkingConfigValue,
) -> GnsResult<GnsConfigValue>
pub fn get_connection_config_value( &self, conn: GnsConnection, typ: ESteamNetworkingConfigValue, ) -> GnsResult<GnsConfigValue>
Reads a configuration value from one connection, the counterpart of
Self::set_connection_config_value.
A value that was never set on the connection itself comes back from the enclosing scope, such as the listen socket or the global defaults.
Sourcepub fn get_config_value_info(
&self,
typ: ESteamNetworkingConfigValue,
) -> Option<(&'static str, ESteamNetworkingConfigDataType, ESteamNetworkingConfigScope)>
pub fn get_config_value_info( &self, typ: ESteamNetworkingConfigValue, ) -> Option<(&'static str, ESteamNetworkingConfigDataType, ESteamNetworkingConfigScope)>
Returns the name, data type, and maximally specific scope of a
configuration value, or None if the value is unknown.
Sourcepub fn local_timestamp(&self) -> SteamNetworkingMicroseconds
pub fn local_timestamp(&self) -> SteamNetworkingMicroseconds
Returns the current local timestamp, in microseconds.
The timebase starts at a value that will never be confused with an
interval, and it matches GnsNetworkMessage::time_received.