Class MessageAction
A type-dispatching action map that routes an IMessage to a registered callback based on its MessageTypeId.
Inherited Members
Namespace: Unity.SimulationPro.Foundation
Assembly: Unity.SimulationPro.Foundation.dll
Syntax
public class MessageAction
Methods
Add(MessageTypeId, Action<IMessage>)
Registers a callback for messages with the given MessageTypeId.
Declaration
public void Add(MessageTypeId messageTypeName, Action<IMessage> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageTypeId | messageTypeName | The message type ID to dispatch on. |
| Action<IMessage> | callback | The action to invoke when a matching message is received. |
Add<T>(Action<T>)
Registers a strongly-typed callback for messages of type T.
Declaration
public void Add<T>(Action<T> callback) where T : IMessage
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T> | callback | The typed action to invoke when a message of type |
Type Parameters
| Name | Description |
|---|---|
| T | The concrete IMessage type to handle. |
Invoke(IMessage)
Dispatches the message to the registered callback matching its MessageTypeId.
Declaration
public void Invoke(IMessage msg)
Parameters
| Type | Name | Description |
|---|---|---|
| IMessage | msg | The message to dispatch. |
Exceptions
| Type | Condition |
|---|---|
| NotImplementedException | Thrown if no callback is registered for the message type. |