pub struct NetcodeServerTransport { /* private fields */ }
netcode
only.Implementations§
Source§impl NetcodeServerTransport
impl NetcodeServerTransport
Sourcepub fn new(
server_config: ServerSetupConfig,
socket: impl ServerSocket,
) -> Result<NetcodeServerTransport, Error>
pub fn new( server_config: ServerSetupConfig, socket: impl ServerSocket, ) -> Result<NetcodeServerTransport, Error>
Makes a new server transport that uses netcode
for managing connections and data flow.
Sourcepub fn new_with_sockets(
server_config: ServerSetupConfig,
boxed: Vec<BoxedSocket>,
) -> Result<NetcodeServerTransport, Error>
pub fn new_with_sockets( server_config: ServerSetupConfig, boxed: Vec<BoxedSocket>, ) -> Result<NetcodeServerTransport, Error>
Makes a new server transport that uses netcode
for managing connections and data flow.
Multiple ServerSockets
may be inserted. Each socket must line
up 1:1 with socket entries in ServerSetupConfig::socket_addresses
.
Sourcepub fn addresses(&self) -> Vec<SocketAddr>
pub fn addresses(&self) -> Vec<SocketAddr>
Returns the server’s public addresses for the first transport socket.
Sourcepub fn get_addresses(&self, socket_id: usize) -> Option<Vec<SocketAddr>>
pub fn get_addresses(&self, socket_id: usize) -> Option<Vec<SocketAddr>>
Returns the server’s public addresses for a given socket_id
.
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: u64) -> Option<[u8; 256]>
pub fn user_data(&self, client_id: u64) -> Option<[u8; 256]>
Returns the user data for client if connected.
Sourcepub fn client_addr(&self, client_id: u64) -> Option<(usize, SocketAddr)>
pub fn client_addr(&self, client_id: u64) -> Option<(usize, SocketAddr)>
Returns the client socket id and 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 otherwise.
Sourcepub fn time_since_last_received_packet(
&self,
client_id: u64,
) -> Option<Duration>
pub fn time_since_last_received_packet( &self, client_id: u64, ) -> Option<Duration>
Returns the duration since the connected client last received a packet.
Useful to detect users that are timing out.
Sourcepub fn update(
&mut self,
duration: Duration,
server: &mut RenetServer,
) -> Result<(), Vec<NetcodeTransportError>>
pub fn update( &mut self, duration: Duration, server: &mut RenetServer, ) -> Result<(), Vec<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)
Sends packets to connected clients.
Trait Implementations§
Source§impl Debug for NetcodeServerTransport
impl Debug for NetcodeServerTransport
impl Resource for NetcodeServerTransport
Auto Trait Implementations§
impl Freeze for NetcodeServerTransport
impl !RefUnwindSafe for NetcodeServerTransport
impl Send for NetcodeServerTransport
impl Sync for NetcodeServerTransport
impl Unpin for NetcodeServerTransport
impl !UnwindSafe for NetcodeServerTransport
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more