Struct naia_client::Client
source · pub struct Client<E: Copy + Eq + Hash + Send + Sync> { /* 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§
source§impl<E: Copy + Eq + Hash + Send + Sync> Client<E>
impl<E: Copy + Eq + Hash + Send + Sync> Client<E>
sourcepub fn new<P: Into<Protocol>>(client_config: ClientConfig, protocol: P) -> Self
pub fn new<P: Into<Protocol>>(client_config: ClientConfig, protocol: P) -> Self
Create a new Client
sourcepub fn auth<M: Message>(&mut self, auth: M)
pub fn auth<M: Message>(&mut self, auth: M)
Set the auth object to use when setting up a connection with the Server
sourcepub fn connect<S: Into<Box<dyn Socket>>>(&mut self, socket: S)
pub fn connect<S: Into<Box<dyn Socket>>>(&mut self, socket: S)
Connect to the given server address
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 socket_config(&self) -> &SocketConfig
pub fn socket_config(&self) -> &SocketConfig
Returns socket config
sourcepub fn receive<W: WorldMutType<E>>(&mut self, world: W) -> Events<E>
pub fn receive<W: WorldMutType<E>>(&mut self, world: W) -> Events<E>
Must call this regularly (preferably at the beginning of every draw frame), in a loop until it returns None. Retrieves incoming update data from the server, and maintains the connection.
sourcepub fn send_message<C: Channel, M: Message>(&mut self, message: &M)
pub fn send_message<C: Channel, M: Message>(&mut self, message: &M)
Queues up an Message to be sent to the Server
pub fn send_tick_buffer_message<C: Channel, M: Message>( &mut self, tick: &Tick, message: &M )
sourcepub fn spawn_entity<W: WorldMutType<E>>(
&mut self,
world: W
) -> EntityMut<'_, E, W>
pub fn spawn_entity<W: WorldMutType<E>>( &mut self, world: W ) -> EntityMut<'_, E, W>
Creates a new Entity and returns an EntityMut which can be used for further operations on the Entity
sourcepub fn entity<W: WorldRefType<E>>(
&self,
world: W,
entity: &E
) -> EntityRef<'_, E, W>
pub fn entity<W: WorldRefType<E>>( &self, world: W, entity: &E ) -> EntityRef<'_, E, W>
Retrieves an EntityRef that exposes read-only operations for the given Entity. Panics if the Entity does not exist.
sourcepub fn entity_mut<W: WorldMutType<E>>(
&mut self,
world: W,
entity: &E
) -> EntityMut<'_, E, W>
pub fn entity_mut<W: WorldMutType<E>>( &mut self, world: W, entity: &E ) -> EntityMut<'_, E, W>
Retrieves an EntityMut that exposes read and write operations for the Entity. Panics if the Entity does not exist.
sourcepub fn entities<W: WorldRefType<E>>(&self, world: &W) -> Vec<E>
pub fn entities<W: WorldRefType<E>>(&self, world: &W) -> Vec<E>
Return a list of all Entities
pub fn entity_owner(&self, entity: &E) -> EntityOwner
sourcepub fn enable_entity_replication(&mut self, entity: &E)
pub fn enable_entity_replication(&mut self, entity: &E)
This is used only for Hecs/Bevy adapter crates, do not use otherwise!
sourcepub fn disable_entity_replication(&mut self, entity: &E)
pub fn disable_entity_replication(&mut self, entity: &E)
This is used only for Hecs/Bevy adapter crates, do not use otherwise!
sourcepub fn entity_replication_config(&self, entity: &E) -> Option<ReplicationConfig>
pub fn entity_replication_config(&self, entity: &E) -> Option<ReplicationConfig>
This is used only for Hecs/Bevy adapter crates, do not use otherwise!
sourcepub fn configure_entity_replication<W: WorldMutType<E>>(
&mut self,
world: &mut W,
entity: &E,
config: ReplicationConfig
)
pub fn configure_entity_replication<W: WorldMutType<E>>( &mut self, world: &mut W, entity: &E, config: ReplicationConfig )
This is used only for Hecs/Bevy adapter crates, do not use otherwise!
This is used only for Hecs/Bevy adapter crates, do not use otherwise!
This is used only for Hecs/Bevy adapter crates, do not use otherwise!
This is used only for Hecs/Bevy adapter crates, do not use otherwise!
sourcepub fn server_address(&self) -> Result<SocketAddr, NaiaClientError>
pub fn server_address(&self) -> Result<SocketAddr, NaiaClientError>
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 server_tick(&self) -> Option<Tick>
pub fn server_tick(&self) -> Option<Tick>
Gets the current tick of the Server
sourcepub fn client_interpolation(&self) -> Option<f32>
pub fn client_interpolation(&self) -> Option<f32>
Gets the interpolation tween amount for the current frame, for use by entities on the Client Tick (i.e. predicted)
sourcepub fn server_interpolation(&self) -> Option<f32>
pub fn server_interpolation(&self) -> Option<f32>
Gets the interpolation tween amount for the current frame, for use by entities on the Server Tick (i.e. authoritative)