Table of Contents

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
object
LocalMessageBus
Implements

Fields

DebugToLog

If true, all published messages will be logged for debugging purposes.

public bool DebugToLog

Field Value

bool

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

sender TSender

The entity sending the message.

msg TMessage

The message to publish.

Type Parameters

TSender

The type of the sender of the message.

TMessage

The 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

handler Action<TSender, TMessage>

The handler delegate to invoke when messages are published.

Returns

BusSubscription

A subscription token that can be disposed to unsubscribe.

Type Parameters

TSender

The type of the sender of the message.

TMessage

The type of message to subscribe to.