Event Channel
Mechanism Overview
To address cases where some listeners do not need to respond to all triggers of a specific event, a channel mechanism is introduced.
In principle, only events broadcasted and registered with the same channel will be triggered (if no channel is specified, all will be triggered).
- Invoking with
None
will trigger all listeners (regardless of whether the listener has a specific channel). - Invoking with a specific channel will trigger only those listeners registered to the same channel.
- A listener set to
None
will receive all invokes (regardless of the invoke channel). - A listener registered to a specific channel will receive only those invokes with the same channel.
Channel Assignment
The UDidaEventLibrary::GetObjectChannel
interface provides a way to dynamically generate channels using an object.
By default, this function will return the same key for identical objects, allowing events from the same channel to be specified for listening.
In most cases, channels are defined by the information of a particular event. Thus, even if channels share the same name, they will not conflict across different events.
Overriding Channels
An object can inherit IDidaEventChannelInterface
to override the ReplaceObjectChannel
interface and change the way channels are computed. Note that if the function returns false
, the default conversion method will still be applied.
For example, a controller’s calculation could be defined to be based on PlayerId
, which would conveniently allow cross-end channel interaction.
Special calculations currently available are documented in: Special Channel Rules Summary
Note that if the channel is dynamic, the logic dependent on the channel must handle order and timing issues appropriately.
Magic Channels
To address situations where listeners need to specify channels before runtime, which can limit the applicability of setting default values for event listeners, a “magic channel” mechanism is introduced. This mechanism can also be used directly at runtime.
The basic principle is: set a special category of Name
; if these Names
are detected during listener creation, they will automatically convert to another channel.
Magic channels allow default values to be assigned directly to event listeners, avoiding the need to specify them at runtime.
Be mindful of the registration timing and the order of dependencies between related magic channels to avoid cases where required objects are not available at listener creation.