Struct naia_client::Client
source · [−]pub struct Client<P: ProtocolType, E: Copy + Eq + Hash> { /* 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
Create a new Client
Connect to the given server address
Set the auth object to use when setting up a connection with the Server
Queues up an Message to be sent to the Server
Queues up a Command for an assigned Entity to be sent to the Server
pub fn entity<'s, W: WorldRefType<P, E>>(
&'s self,
world: W,
entity: &E
) -> EntityRef<'s, P, E, W>
pub fn entity<'s, W: WorldRefType<P, E>>(
&'s self,
world: W,
entity: &E
) -> EntityRef<'s, P, E, W>
Retrieves an EntityRef that exposes read-only operations for the given Entity. Panics if the Entity does not exist.
Return a list of all Entities
Get the address currently associated with the Server
Return whether or not a connection has been established with the Server
Gets the current tick of the Client
Gets the last received tick from the Server
Gets the interpolation tween amount for the current frame
pub fn receive<W: WorldMutType<P, E>>(
&mut self,
world: W
) -> VecDeque<Result<Event<P, E>, NaiaClientError>>
pub fn receive<W: WorldMutType<P, E>>(
&mut self,
world: W
) -> VecDeque<Result<Event<P, E>, 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.