ClientEventAppExt

Trait ClientEventAppExt 

Source
pub trait ClientEventAppExt {
    // Required method
    fn add_client_event_with<E: Event>(
        &mut self,
        channel: Channel,
        serialize: SerializeFn<ClientSendCtx<'_>, E>,
        deserialize: DeserializeFn<ServerReceiveCtx<'_>, E>,
    ) -> &mut Self;

    // Provided methods
    fn add_client_event<E: Event + Serialize + DeserializeOwned>(
        &mut self,
        channel: Channel,
    ) -> &mut Self { ... }
    fn add_mapped_client_event<E: Event + Serialize + DeserializeOwned + MapEntities + Clone>(
        &mut self,
        channel: Channel,
    ) -> &mut Self { ... }
}
Expand description

An extension trait for App for creating client events.

See also ClientTriggerExt for triggering, ServerEventAppExt for server events and ClientMessageAppExt for messages.

Required Methods§

Source

fn add_client_event_with<E: Event>( &mut self, channel: Channel, serialize: SerializeFn<ClientSendCtx<'_>, E>, deserialize: DeserializeFn<ServerReceiveCtx<'_>, E>, ) -> &mut Self

Same as Self::add_client_event, but uses the specified functions for serialization and deserialization.

See also ClientMessageAppExt::add_client_message_with.

Provided Methods§

Source

fn add_client_event<E: Event + Serialize + DeserializeOwned>( &mut self, channel: Channel, ) -> &mut Self

Registers a remote event that can be triggered using ClientTriggerExt::client_trigger.

After triggering E event on the client, FromClient<E> event will be triggered on the server.

If ServerMessagePlugin is enabled and the client state is ClientState::Disconnected, the event will also be triggered locally as FromClient<E> event with FromClient::client_id equal to ClientId::Server.

See also the corresponding section from the quick start guide.

Source

fn add_mapped_client_event<E: Event + Serialize + DeserializeOwned + MapEntities + Clone>( &mut self, channel: Channel, ) -> &mut Self

Same as Self::add_client_event, but additionally maps client entities to server inside the event before sending.

Always use it for events that contain entities. Entities must be annotated with #[entities]. For details, see Component::map_entities.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ClientEventAppExt for App

Source§

fn add_client_event_with<E: Event>( &mut self, channel: Channel, serialize: SerializeFn<ClientSendCtx<'_>, E>, deserialize: DeserializeFn<ServerReceiveCtx<'_>, E>, ) -> &mut Self

Implementors§