Struct naia_client::Client
source · [−]pub struct Client<P: Protocolize, E: Copy + Eq + Hash, C: ChannelIndex> { /* private fields */ }
Expand description
Client can send/receive messages to/from a server, and has a pool of in-scope entities/components that are synced with the server
Implementations
sourceimpl<P: Protocolize, E: Copy + Eq + Hash, C: ChannelIndex> Client<P, E, C>
impl<P: Protocolize, E: Copy + Eq + Hash, C: ChannelIndex> Client<P, E, C>
sourcepub fn new(
client_config: &ClientConfig,
shared_config: &SharedConfig<C>
) -> Self
pub fn new(
client_config: &ClientConfig,
shared_config: &SharedConfig<C>
) -> Self
Create a new Client
sourcepub fn auth<R: ReplicateSafe<P>>(&mut self, auth: R)
pub fn auth<R: ReplicateSafe<P>>(&mut self, auth: R)
Set the auth object to use when setting up a connection with the Server
sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns whether or not the client is disconnected
sourcepub fn is_connecting(&self) -> bool
pub fn is_connecting(&self) -> bool
Returns whether or not a connection is being established with the Server
sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns whether or not a connection has been established with the Server
sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
Disconnect from Server
sourcepub fn receive<W: WorldMutType<P, E>>(
&mut self,
world: W
) -> VecDeque<Result<Event<P, E, C>, NaiaClientError>>
pub fn receive<W: WorldMutType<P, E>>(
&mut self,
world: W
) -> VecDeque<Result<Event<P, E, C>, NaiaClientError>>
Must call this regularly (preferably at the beginning of every draw frame), in a loop until it returns None. Retrieves incoming update data, and maintains the connection.
sourcepub fn send_message<R: ReplicateSafe<P>>(&mut self, channel: C, message: &R)
pub fn send_message<R: ReplicateSafe<P>>(&mut self, channel: C, message: &R)
Queues up an Message to be sent to the Server
sourcepub fn entity<W: WorldRefType<P, E>>(
&self,
world: W,
entity: &E
) -> EntityRef<P, E, W>
pub fn entity<W: WorldRefType<P, E>>(
&self,
world: W,
entity: &E
) -> EntityRef<P, E, W>
Retrieves an EntityRef that exposes read-only operations for the given Entity. Panics if the Entity does not exist.
sourcepub fn entities<W: WorldRefType<P, E>>(&self, world: &W) -> Vec<E>
pub fn entities<W: WorldRefType<P, E>>(&self, world: &W) -> Vec<E>
Return a list of all Entities
sourcepub fn server_address(&self) -> SocketAddr
pub fn server_address(&self) -> SocketAddr
Get the address currently associated with the Server
sourcepub fn client_tick(&self) -> Option<Tick>
pub fn client_tick(&self) -> Option<Tick>
Gets the current tick of the Client
sourcepub fn interpolation(&self) -> Option<f32>
pub fn interpolation(&self) -> Option<f32>
Gets the interpolation tween amount for the current frame
pub fn outgoing_bandwidth(&mut self) -> f32
pub fn incoming_bandwidth(&mut self) -> f32
Trait Implementations
sourceimpl<P: Protocolize, E: Copy + Eq + Hash, C: ChannelIndex> EntityHandleConverter<E> for Client<P, E, C>
impl<P: Protocolize, E: Copy + Eq + Hash, C: ChannelIndex> EntityHandleConverter<E> for Client<P, E, C>
fn handle_to_entity(&self, entity_handle: &EntityHandle) -> E
fn entity_to_handle(&self, entity: &E) -> EntityHandle
Auto Trait Implementations
impl<P, E, C> !RefUnwindSafe for Client<P, E, C>
impl<P, E, C> Send for Client<P, E, C> where
E: Send,
impl<P, E, C> Sync for Client<P, E, C> where
E: Sync,
impl<P, E, C> Unpin for Client<P, E, C> where
C: Unpin,
E: Unpin,
P: Unpin,
<P as Protocolize>::Kind: Unpin,
impl<P, E, C> !UnwindSafe for Client<P, E, C>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more