Defining Events
Events are plain Go structs that embedBaseEvent and implement the Event interface. This interface requires a single Name() method that returns a unique string identifier.
Emitting Events
Just like with commands, you must register an event type with the world beforeStartGame:
w.Broadcast to emit the event to every subscribed client:
w.SendTo(persona, event) instead to deliver the event only to one persona. If that persona has no open event stream, the event is dropped.
Just like with commands, an event type must be registered before it is sent.
Broadcast and
SendTo panic for an unregistered event type.Subscribing to Events
Events emitted during a tick are collected and broadcast to subscribers at the end of that tick. While events are broadcast, clients must explicitly subscribe to receive them. Subscribe to an event by passing the event name and a handler function:- Unity C#
- TypeScript
- Unity C#
- TypeScript