View Source ECSx.ClientEvents (ECSx v0.5.1)
A store to which clients can write, for communication with the ECSx backend.
Events are created from the client process by calling add/2
, then retrieved by the handler
system using get_and_clear/0
. You will be required to create the handler system yourself -
see the tutorial project for a detailed example.
Link to this section Summary
Link to this section Types
@type id() :: any()
Link to this section Functions
Add a new client event.
The first argument is the entity which spawned the event. The second argument can be any representation of the event, usually either an atom or a tuple containing an atom name along with additional metadata.
examples
Examples
# Simple event requiring no metadata
ECSx.ClientEvents.add(player_id, :spawn_player)
# Event with metadata
ECSx.ClientEvents.add(player_id, {:send_message_to, recipient_id, message})
Returns the list of events, simultaneously clearing it.
This function guarantees that each event is returned exactly once.