Struct naia_hecs_client::Client
source · pub struct Client<E>where
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> Client<E>where
E: Copy + Eq + Hash + Send + Sync,
impl<E> Client<E>where E: Copy + Eq + Hash + Send + Sync,
sourcepub fn new<P>(client_config: ClientConfig, protocol: P) -> Client<E>where
P: Into<Protocol>,
pub fn new<P>(client_config: ClientConfig, protocol: P) -> Client<E>where P: Into<Protocol>,
Create a new Client
sourcepub fn auth<M>(&mut self, auth: M)where
M: Message,
pub fn auth<M>(&mut self, auth: M)where M: Message,
Set the auth object to use when setting up a connection with the Server
sourcepub fn connect<S>(&mut self, socket: S)where
S: Into<Box<dyn Socket + 'static, Global>>,
pub fn connect<S>(&mut self, socket: S)where S: Into<Box<dyn Socket + 'static, Global>>,
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>(&mut self, world: W) -> Events<E>where
W: WorldMutType<E>,
pub fn receive<W>(&mut self, world: W) -> Events<E>where W: WorldMutType<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, M>(&mut self, message: &M)where
C: Channel,
M: Message,
pub fn send_message<C, M>(&mut self, message: &M)where C: Channel, M: Message,
Queues up an Message to be sent to the Server
pub fn send_tick_buffer_message<C, M>(&mut self, tick: &u16, message: &M)where C: Channel, M: Message,
pub fn enable_replication(&mut self, entity: &E)
pub fn disable_replication(&mut self, entity: &E)
sourcepub fn spawn_entity<W>(&mut self, world: W) -> EntityMut<'_, E, W>where
W: WorldMutType<E>,
pub fn spawn_entity<W>(&mut self, world: W) -> EntityMut<'_, E, W>where W: WorldMutType<E>,
Creates a new Entity and returns an EntityMut which can be used for further operations on the Entity
sourcepub fn spawn_entity_at(&mut self, entity: &E)
pub fn spawn_entity_at(&mut self, entity: &E)
Creates a new Entity with a specific id
sourcepub fn entity<W>(&self, world: W, entity: &E) -> EntityRef<E, W>where
W: WorldRefType<E>,
pub fn entity<W>(&self, world: W, entity: &E) -> EntityRef<E, W>where W: WorldRefType<E>,
Retrieves an EntityRef that exposes read-only operations for the given Entity. Panics if the Entity does not exist.
sourcepub fn entity_mut<W>(&mut self, world: W, entity: &E) -> EntityMut<'_, E, W>where
W: WorldMutType<E>,
pub fn entity_mut<W>(&mut self, world: W, entity: &E) -> EntityMut<'_, E, W>where W: WorldMutType<E>,
Retrieves an EntityMut that exposes read and write operations for the Entity. Panics if the Entity does not exist.
sourcepub fn entities<W>(&self, world: &W) -> Vec<E, Global>where
W: WorldRefType<E>,
pub fn entities<W>(&self, world: &W) -> Vec<E, Global>where W: WorldRefType<E>,
Return a list of all Entities
pub fn entity_owner(&self, entity: &E) -> EntityOwner
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<u16>
pub fn client_tick(&self) -> Option<u16>
Gets the current tick of the Client
sourcepub fn server_tick(&self) -> Option<u16>
pub fn server_tick(&self) -> Option<u16>
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)