pub struct NetcodeClientTransport { /* private fields */ }netcode only.Implementations§
Source§impl NetcodeClientTransport
impl NetcodeClientTransport
Sourcepub fn new(
current_time: Duration,
authentication: ClientAuthentication,
socket: impl ClientSocket,
) -> Result<NetcodeClientTransport, NetcodeError>
pub fn new( current_time: Duration, authentication: ClientAuthentication, socket: impl ClientSocket, ) -> Result<NetcodeClientTransport, 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, Error>
pub fn addr(&self) -> Result<SocketAddr, Error>
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 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 UnsafeUnpin 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>, 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