===== IMessageBroker ===== This service provides the central messaging system used for communication between components. It allows subscribers to listen for synchronous or asynchronous Topics broadcast by a specific sender and maintains the relationships between subscribers and broadcasters. A Topic is restricted to a single broadcaster type to prevent multiple unrelated systems from broadcasting the same Topic. === Methods === ^Method | [[IMessageBrokerSubscription]] **Subscribe**(object subscriber, object sender, [[EventCallback]] callback) | ^Description | Subscribes specified subscriber to synchronous Topic T1 broadcast by specified sender. T1 must derive from [[Topic]] and T2 must derive from [[BaseMessage]]. The supplied callback is invoked whenever the sender broadcasts the Topic. A Topic can only be associated with one broadcaster type. If a conflicting broadcaster attempts to use the same Topic, the subscription is rejected and the error is logged. Returns an [[IMessageBrokerSubscription]] associated with the subscription. | ^Method | [[IMessageBrokerSubscription]] **SubscribeAsync**(object subscriber, object sender, [[AsyncEventCallback]] callback) | ^Description | Subscribes specified subscriber to asynchronous Topic T1 broadcast by specified sender. T1 must derive from [[AsyncTopic]] and T2 must derive from [[BaseMessage]]. The supplied callback is invoked whenever the sender broadcasts the Topic asynchronously. A Topic can only be associated with one broadcaster type across synchronous and asynchronous subscriptions. If a conflicting broadcaster attempts to use the same Topic, the subscription is rejected and the error is logged. Returns an [[IMessageBrokerSubscription]] associated with the subscription. | ^Method | void **Broadcast**(object sender, T1 topic, T2 message) | ^Description | Broadcasts synchronous Topic T1 with supplied message from specified sender. T1 must derive from [[Topic]] and T2 must derive from [[BaseMessage]]. All callbacks subscribed to the Topic from the specified sender are invoked. Exceptions thrown by individual callbacks are logged without preventing the remaining callbacks from being invoked. Broadcasting a Topic from a broadcaster type different from the one already associated with that Topic is rejected and logged. | ^Method | Task **BroadcastAsync**(object sender, T1 topic, T2 message, CancellationToken cancellationToken) | ^Description | Broadcasts asynchronous Topic T1 with supplied message from specified sender. T1 must derive from [[AsyncTopic]] and T2 must derive from [[BaseMessage]]. All callbacks subscribed to the Topic from the specified sender are executed asynchronously and the returned Task completes once all callbacks have completed. Nothing happens if there are no subscribers for the Topic. Broadcasting a Topic from a broadcaster type different from the one already associated with that Topic is rejected and logged. | ^Method | void **UnregisterSubscriber**(object subscriber) | ^Description | Removes all synchronous and asynchronous subscriptions belonging to specified subscriber from every broadcaster it is subscribed to. The subscriber is also removed from the Message Broker's subscriber-to-broadcaster mappings. | ^Method | void **UnregisterBroadcaster**(object sender) | ^Description | Removes specified broadcaster and all synchronous and asynchronous subscriptions associated with it. References to the broadcaster are also removed from all subscribers that were subscribed to it. | ^Method | void **UnregisterSubscriberFromBroadcaster**(object subscriber, object broadcaster) | ^Description | Removes all synchronous and asynchronous subscriptions belonging to specified subscriber that listen to specified broadcaster. Subscriptions the subscriber has to other broadcasters and subscriptions other subscribers have to the specified broadcaster remain unaffected. |