pub struct NetworkingUtils<Manager> { /* private fields */ }
Expand description

Access to the steam networking sockets interface

Implementations§

source§

impl<Manager> NetworkingUtils<Manager>

source

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.

source

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.

source

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.

source

pub fn detailed_relay_network_status(&self) -> RelayNetworkStatus

Fetch current detailed status of the relay network.

source

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.

Trait Implementations§

Auto Trait Implementations§

§

impl<Manager> RefUnwindSafe for NetworkingUtils<Manager>
where Manager: RefUnwindSafe,

§

impl<Manager> Unpin for NetworkingUtils<Manager>

§

impl<Manager> UnwindSafe for NetworkingUtils<Manager>
where Manager: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.