Class LocalMessageBus
- Namespace
- LiteEntitySystem.Extensions
- Assembly
- LiteEntitySystem.dll
A local message bus for publishing and subscribing to typed messages within a local singleton context.
public sealed class LocalMessageBus : ILocalSingleton
- Inheritance
-
objectLocalMessageBus
- Implements
Fields
DebugToLog
If true, all published messages will be logged for debugging purposes.
public bool DebugToLog
Field Value
Methods
Destroy()
Destroys the message bus, disposing all channels and unsubscribing all handlers.
public void Destroy()
Send<TSender, TMessage>(TSender, in TMessage)
Publishes a message to all subscribers.
public void Send<TSender, TMessage>(TSender sender, in TMessage msg) where TMessage : struct, IBusMessage<TSender>
Parameters
senderTSenderThe entity sending the message.
msgTMessageThe message to publish.
Type Parameters
TSenderThe type of the sender of the message.
TMessageThe type of message to publish.
Subscribe<TSender, TMessage>(Action<TSender, TMessage>)
Subscribes a handler to receive messages of a specific type.
public BusSubscription Subscribe<TSender, TMessage>(Action<TSender, TMessage> handler) where TMessage : struct, IBusMessage<TSender>
Parameters
handlerAction<TSender, TMessage>The handler delegate to invoke when messages are published.
Returns
- BusSubscription
A subscription token that can be disposed to unsubscribe.
Type Parameters
TSenderThe type of the sender of the message.
TMessageThe type of message to subscribe to.