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

A socket that will continually listen for client connections. Call events() to receive incoming connection. You should regularly check for events and answer ConnectionRequests requests immediately or the socket will appear as unresponsive to the client.

If a Listen Socket goes out of scope while there are still connections, but new requests will be rejected immediately.

Listen Socket Events will only be available if steam callback are regularly called.

Implementations§

source§

impl<Manager: 'static> ListenSocket<Manager>

source

pub fn try_receive_event(&self) -> Option<ListenSocketEvent<Manager>>

Tries to receive a pending event. This will never block.

You should answer ConnectionRequests immediately or the server will appear as unresponsive.

source

pub fn receive_event(&self) -> ListenSocketEvent<Manager>

Receive the next event. This will block until the next event is received.

You should answer ConnectionRequests immediately or the server will appear as unresponsive.

source

pub fn events<'a>( &'a self ) -> impl Iterator<Item = ListenSocketEvent<Manager>> + 'a

Returns an iterator for ListenSocketEvents that will block until the next event is received

You should answer ConnectionRequests immediately or the server will appear as unresponsive.

source

pub fn send_messages( &self, messages: impl IntoIterator<Item = NetworkingMessage<Manager>> ) -> Vec<SResult<MessageNumber>>

Send one or more messages without copying the message payload. This is the most efficient way to send messages. To use this function, you must first allocate a message object using ISteamNetworkingUtils::AllocateMessage. (Do not declare one on the stack or allocate your own.)

You should fill in the message payload. You can either let it allocate the buffer for you and then fill in the payload, or if you already have a buffer allocated, you can just point m_pData at your buffer and set the callback to the appropriate function to free it. Note that if you use your own buffer, it MUST remain valid until the callback is executed. And also note that your callback can be invoked at ant time from any thread (perhaps even before SendMessages returns!), so it MUST be fast and threadsafe.

You MUST also fill in:

  • m_conn - the handle of the connection to send the message to
  • m_nFlags - bitmask of k_nSteamNetworkingSend_xxx flags.

All other fields are currently reserved and should not be modified.

The library will take ownership of the message structures. They may be modified or become invalid at any time, so you must not read them after passing them to this function.

Returns the message number or Steam error for each sent message.

Trait Implementations§

source§

impl<Manager: Send + Sync> Send for ListenSocket<Manager>

source§

impl<Manager: Send + Sync> Sync for ListenSocket<Manager>

Auto Trait Implementations§

§

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

§

impl<Manager> Unpin for ListenSocket<Manager>

§

impl<Manager> UnwindSafe for ListenSocket<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.