pub struct NetcodeClientTransport { /* private fields */ }
Implementations§
Source§impl NetcodeClientTransport
impl NetcodeClientTransport
Sourcepub fn new(
current_time: Duration,
authentication: ClientAuthentication,
socket: impl ClientSocket,
) -> Result<Self, NetcodeError>
pub fn new( current_time: Duration, authentication: ClientAuthentication, socket: impl ClientSocket, ) -> Result<Self, NetcodeError>
Makes a new client transport with the given ClientSocket
.
Sourcepub fn is_reliable(&self) -> bool
pub fn is_reliable(&self) -> bool
Gets the internal socket’s ClientSocket::is_reliable
value.
Sourcepub fn addr(&self) -> Result<SocketAddr>
pub fn addr(&self) -> Result<SocketAddr>
Gets the client’s SocketAddr
.
Will return an error if the client doesn’t have an address (e.g. a WebTransport client).
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns true
if the netcode client is connected.
Sourcepub fn is_connecting(&self) -> bool
pub fn is_connecting(&self) -> bool
Returns true
if the netcode client is connecting.
Sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true
if the netcode client is disconnected.
Sourcepub fn time_since_last_received_packet(&self) -> Duration
pub fn time_since_last_received_packet(&self) -> Duration
Returns the duration since the client last received a packet.
Useful to detect timeouts.
Sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
Disconnects the client from the transport layer.
This sends the disconnect packet instantly, use this when closing/exiting games, should use [RenetClient::disconnect][crate::RenetClient::disconnect] otherwise.
Sourcepub fn disconnect_reason(&self) -> Option<DisconnectReason>
pub fn disconnect_reason(&self) -> Option<DisconnectReason>
If the client is disconnected, returns the reason.
Sourcepub fn send_packets(
&mut self,
connection: &mut RenetClient,
) -> Result<(), NetcodeTransportError>
pub fn send_packets( &mut self, connection: &mut RenetClient, ) -> Result<(), NetcodeTransportError>
Sends packets to the server.
Should be called every tick.
Sourcepub fn update(
&mut self,
duration: Duration,
client: &mut RenetClient,
) -> Result<(), NetcodeTransportError>
pub fn update( &mut self, duration: Duration, client: &mut RenetClient, ) -> Result<(), NetcodeTransportError>
Advances the transport by the duration, and receive packets from the network.
Trait Implementations§
Source§impl Debug for NetcodeClientTransport
impl Debug for NetcodeClientTransport
impl Resource for NetcodeClientTransport
Auto Trait Implementations§
impl Freeze for NetcodeClientTransport
impl !RefUnwindSafe for NetcodeClientTransport
impl Send for NetcodeClientTransport
impl Sync for NetcodeClientTransport
impl Unpin for NetcodeClientTransport
impl !UnwindSafe for NetcodeClientTransport
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>
. Box<dyn Any>
can
then be further downcast
into Box<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>
. Rc<Any>
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.