Build with Rivet
Events
Events are used for clients to receive realtime data from actors.
Info
Events are used for actors to publish updates to clients. Clients call RPCs to communicate with the actor.
Publishing from actors
Actors can publish events to clients using this.broadcast
and connection.send
.
Broadcasting events
Actors can publish events to all connected clients with this.broadcast(name, data)
. For example:
Sending events to specific connections
Actors can send messages to specific client connections. All connections are available on the this.connections
array. For example:
Subscribing from clients
Clients can subscribe to events from actors using on
and once
.
on
Clients can subscribe to events that will happen repeatedly using actor.on(name, callback)
.
For example:
once
Clients can listen for an event only one time with actor.once(name, callback)
.
For example:
Connections
Connections are used to communicate with clients from the actor.
Read more about connections here.