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>

source

pub fn new<P: Into<Protocol>>(client_config: ClientConfig, protocol: P) -> Self

Create a new Client

source

pub fn auth<M: Message>(&mut self, auth: M)

Set the auth object to use when setting up a connection with the Server

source

pub fn connect<S: Into<Box<dyn Socket>>>(&mut self, socket: S)

Connect to the given server address

source

pub fn is_disconnected(&self) -> bool

Returns whether or not the client is disconnected

source

pub fn is_connecting(&self) -> bool

Returns whether or not a connection is being established with the Server

source

pub fn is_connected(&self) -> bool

Returns whether or not a connection has been established with the Server

source

pub fn disconnect(&mut self)

Disconnect from Server

source

pub fn socket_config(&self) -> &SocketConfig

Returns socket config

source

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.

source

pub fn send_message<C: Channel, M: Message>(&mut self, message: &M)

Queues up an Message to be sent to the Server

source

pub fn send_tick_buffer_message<C: Channel, M: Message>( &mut self, tick: &Tick, message: &M )

source

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

source

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.

source

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.

source

pub fn entities<W: WorldRefType<E>>(&self, world: &W) -> Vec<E>

Return a list of all Entities

source

pub fn entity_owner(&self, entity: &E) -> EntityOwner

source

pub fn enable_entity_replication(&mut self, entity: &E)

This is used only for Hecs/Bevy adapter crates, do not use otherwise!

source

pub fn disable_entity_replication(&mut self, entity: &E)

This is used only for Hecs/Bevy adapter crates, do not use otherwise!

source

pub fn entity_replication_config(&self, entity: &E) -> Option<ReplicationConfig>

This is used only for Hecs/Bevy adapter crates, do not use otherwise!

source

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!

source

pub fn entity_authority_status(&self, entity: &E) -> Option<EntityAuthStatus>

This is used only for Hecs/Bevy adapter crates, do not use otherwise!

source

pub fn entity_request_authority(&mut self, entity: &E)

This is used only for Hecs/Bevy adapter crates, do not use otherwise!

source

pub fn entity_release_authority(&mut self, entity: &E)

This is used only for Hecs/Bevy adapter crates, do not use otherwise!

source

pub fn server_address(&self) -> Result<SocketAddr, NaiaClientError>

Get the address currently associated with the Server

source

pub fn rtt(&self) -> f32

Gets the average Round Trip Time measured to the Server

source

pub fn jitter(&self) -> f32

Gets the average Jitter measured in connection to the Server

source

pub fn client_tick(&self) -> Option<Tick>

Gets the current tick of the Client

source

pub fn server_tick(&self) -> Option<Tick>

Gets the current tick of the Server

source

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)

source

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)

source

pub fn outgoing_bandwidth(&mut self) -> f32

source

pub fn incoming_bandwidth(&mut self) -> f32

source

pub fn despawn_entity_worldless(&mut self, entity: &E)

source

pub fn insert_component_worldless( &mut self, entity: &E, component: &mut dyn Replicate )

source

pub fn remove_component_worldless( &mut self, entity: &E, component_kind: &ComponentKind )

source

pub fn add_redundant_remote_entity_to_host( &mut self, world_entity: &E, remote_entity: RemoteEntity )

Trait Implementations§

Auto Trait Implementations§

§

impl<E> !RefUnwindSafe for Client<E>

§

impl<E> Send for Client<E>

§

impl<E> Sync for Client<E>

§

impl<E> Unpin for Client<E>
where E: Unpin,

§

impl<E> !UnwindSafe for Client<E>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V