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,

source

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

Create a new Client

source

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

source

pub fn connect<S>(&mut self, socket: S)where S: Into<Box<dyn Socket + 'static, Global>>,

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>(&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.

source

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

source

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

source

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

source

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

source

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

source

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

Creates a new Entity with a specific id

source

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.

source

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.

source

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

Return a list of all Entities

source

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

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<u16>

Gets the current tick of the Client

source

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

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 + 'static) )

source

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

Trait Implementations§

source§

impl<E> EntityAndGlobalEntityConverter<E> for Client<E>where E: Copy + Eq + Hash + Send + Sync,

source§

fn global_entity_to_entity( &self, global_entity: &GlobalEntity ) -> Result<E, EntityDoesNotExistError>

source§

fn entity_to_global_entity( &self, entity: &E ) -> Result<GlobalEntity, EntityDoesNotExistError>

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> Component for Twhere T: Send + Sync + 'static,