pub struct NetcodeServerTransport { /* private fields */ }Implementations§
Source§impl NetcodeServerTransport
impl NetcodeServerTransport
pub fn new( server_config: ServerConfig, socket: UdpSocket, ) -> Result<Self, Error>
Sourcepub fn addresses(&self) -> Vec<SocketAddr>
pub fn addresses(&self) -> Vec<SocketAddr>
Returns the server public address
Sourcepub fn max_clients(&self) -> usize
pub fn max_clients(&self) -> usize
Returns the maximum number of clients that can be connected.
Sourcepub fn set_max_clients(&mut self, max_clients: usize)
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().
Sourcepub fn connected_clients(&self) -> usize
pub fn connected_clients(&self) -> usize
Returns current number of clients connected.
Sourcepub fn user_data(&self, client_id: ClientId) -> Option<[u8; 256]>
pub fn user_data(&self, client_id: ClientId) -> Option<[u8; 256]>
Returns the user data for client if connected.
Sourcepub fn client_addr(&self, client_id: ClientId) -> Option<SocketAddr>
pub fn client_addr(&self, client_id: ClientId) -> Option<SocketAddr>
Returns the client address if connected.
Sourcepub fn disconnect_all(&mut self, server: &mut RenetServer)
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.
Sourcepub fn time_since_last_received_packet(
&self,
client_id: ClientId,
) -> Option<Duration>
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.
Sourcepub fn update(
&mut self,
duration: Duration,
server: &mut RenetServer,
) -> Result<(), NetcodeTransportError>
pub fn update( &mut self, duration: Duration, server: &mut RenetServer, ) -> Result<(), NetcodeTransportError>
Advances the transport by the duration, and receive packets from the network.
Sourcepub fn send_packets(&mut self, server: &mut RenetServer)
pub fn send_packets(&mut self, server: &mut RenetServer)
Send packets to connected clients.