Struct steamworks::networking_utils::NetworkingUtils
source · pub struct NetworkingUtils<Manager> { /* private fields */ }
Expand description
Access to the steam networking sockets interface
Implementations§
source§impl<Manager> NetworkingUtils<Manager>
impl<Manager> NetworkingUtils<Manager>
sourcepub fn allocate_message(&self, buffer_size: usize) -> NetworkingMessage<Manager>
pub fn allocate_message(&self, buffer_size: usize) -> NetworkingMessage<Manager>
Allocate and initialize a message object. Usually the reason you call this is to pass it to ISteamNetworkingSockets::SendMessages. The returned object will have all of the relevant fields cleared to zero.
Optionally you can also request that this system allocate space to hold the payload itself. If cbAllocateBuffer is nonzero, the system will allocate memory to hold a payload of at least cbAllocateBuffer bytes. m_pData will point to the allocated buffer, m_cbSize will be set to the size, and m_pfnFreeData will be set to the proper function to free up the buffer.
If cbAllocateBuffer=0, then no buffer is allocated. m_pData will be NULL, m_cbSize will be zero, and m_pfnFreeData will be NULL. You will need to set each of these.
sourcepub fn init_relay_network_access(&self)
pub fn init_relay_network_access(&self)
If you know that you are going to be using the relay network (for example, because you anticipate making P2P connections), call this to initialize the relay network. If you do not call this, the initialization will be delayed until the first time you use a feature that requires access to the relay network, which will delay that first access.
You can also call this to force a retry if the previous attempt has failed. Performing any action that requires access to the relay network will also trigger a retry, and so calling this function is never strictly necessary, but it can be useful to call it a program launch time, if access to the relay network is anticipated.
Use GetRelayNetworkStatus or listen for SteamRelayNetworkStatus_t callbacks to know when initialization has completed. Typically initialization completes in a few seconds.
Note: dedicated servers hosted in known data centers do not need to call this, since they do not make routing decisions. However, if the dedicated server will be using P2P functionality, it will act as a “client” and this should be called.
sourcepub fn relay_network_status(&self) -> NetworkingAvailabilityResult
pub fn relay_network_status(&self) -> NetworkingAvailabilityResult
Fetch current status of the relay network.
If you want more detailed information use detailed_relay_network_status
instead.
sourcepub fn detailed_relay_network_status(&self) -> RelayNetworkStatus
pub fn detailed_relay_network_status(&self) -> RelayNetworkStatus
Fetch current detailed status of the relay network.
sourcepub fn relay_network_status_callback(
&self,
callback: impl FnMut(RelayNetworkStatus) + Send + 'static
)
pub fn relay_network_status_callback( &self, callback: impl FnMut(RelayNetworkStatus) + Send + 'static )
Register the callback for relay network status updates.
Calling this more than once replaces the previous callback.