Struct NetcodeServerTransport

Source
pub struct NetcodeServerTransport { /* private fields */ }

Implementations§

Source§

impl NetcodeServerTransport

Source

pub fn new( server_config: ServerConfig, socket: UdpSocket, ) -> Result<Self, Error>

Source

pub fn addresses(&self) -> Vec<SocketAddr>

Returns the server public address

Source

pub fn max_clients(&self) -> usize

Returns the maximum number of clients that can be connected.

Source

pub fn set_max_clients(&mut self, max_clients: usize)

Update the maximum numbers of clients that can be connected.

Changing the max_clients to a lower value than the current number of connect clients does not disconnect clients. So NetcodeServerTransport::connected_clients() can return a higher value than NetcodeServerTransport::max_clients().

Source

pub fn connected_clients(&self) -> usize

Returns current number of clients connected.

Source

pub fn user_data(&self, client_id: ClientId) -> Option<[u8; 256]>

Returns the user data for client if connected.

Source

pub fn client_addr(&self, client_id: ClientId) -> Option<SocketAddr>

Returns the client address if connected.

Source

pub fn disconnect_all(&mut self, server: &mut RenetServer)

Disconnects all connected clients. This sends the disconnect packet instantly, use this when closing/exiting games, should use [RenetServer::disconnect_all][crate::RenetServer::disconnect_all] otherwise.

Source

pub fn time_since_last_received_packet( &self, client_id: ClientId, ) -> Option<Duration>

Returns the duration since the connected client last received a packet. Usefull to detect users that are timing out.

Source

pub fn update( &mut self, duration: Duration, server: &mut RenetServer, ) -> Result<(), NetcodeTransportError>

Advances the transport by the duration, and receive packets from the network.

Source

pub fn send_packets(&mut self, server: &mut RenetServer)

Send packets to connected clients.

Trait Implementations§

Source§

impl Debug for NetcodeServerTransport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.