Interface IMessageHub
Messenger hub responsible for taking subscriptions/publications and delivering of messages.
Namespace: Swan.Messaging
Syntax
public interface IMessageHub
Methods
Publish<TMessage>(TMessage)
Publish a message to any subscribers.
Declaration
void Publish<TMessage>(TMessage message)
where TMessage : class, IMessageHubMessage
Parameters
Type | Name | Description |
---|---|---|
TMessage | message | Message to deliver. |
Type Parameters
Name | Description |
---|---|
TMessage | Type of message. |
PublishAsync<TMessage>(TMessage)
Publish a message to any subscribers asynchronously.
Declaration
Task PublishAsync<TMessage>(TMessage message)
where TMessage : class, IMessageHubMessage
Parameters
Type | Name | Description |
---|---|---|
TMessage | message | Message to deliver. |
Returns
Type | Description |
---|---|
Task | A task from Publish action. |
Type Parameters
Name | Description |
---|---|
TMessage | Type of message. |
Subscribe<TMessage>(Action<TMessage>, Func<TMessage, Boolean>, Boolean, IMessageHubProxy)
Subscribe to a message type with the given destination and delivery action with the given filter. Messages will be delivered via the specified proxy. All references are held with WeakReferences Only messages that "pass" the filter will be delivered.
Declaration
MessageHubSubscriptionToken Subscribe<TMessage>(Action<TMessage> deliveryAction, Func<TMessage, bool> messageFilter, bool useStrongReferences, IMessageHubProxy proxy)
where TMessage : class, IMessageHubMessage
Parameters
Type | Name | Description |
---|---|---|
Action<TMessage> | deliveryAction | Action to invoke when message is delivered. |
Func<TMessage, Boolean> | messageFilter | The message filter. |
Boolean | useStrongReferences | Use strong references to destination and deliveryAction. |
IMessageHubProxy | proxy | Proxy to use when delivering the messages. |
Returns
Type | Description |
---|---|
MessageHubSubscriptionToken | MessageSubscription used to unsubscribing. |
Type Parameters
Name | Description |
---|---|
TMessage | Type of message. |
Subscribe<TMessage>(Action<TMessage>, Boolean, IMessageHubProxy)
Subscribe to a message type with the given destination and delivery action. Messages will be delivered via the specified proxy.
All messages of this type will be delivered.
Declaration
MessageHubSubscriptionToken Subscribe<TMessage>(Action<TMessage> deliveryAction, bool useStrongReferences, IMessageHubProxy proxy)
where TMessage : class, IMessageHubMessage
Parameters
Type | Name | Description |
---|---|---|
Action<TMessage> | deliveryAction | Action to invoke when message is delivered. |
Boolean | useStrongReferences | Use strong references to destination and deliveryAction. |
IMessageHubProxy | proxy | Proxy to use when delivering the messages. |
Returns
Type | Description |
---|---|
MessageHubSubscriptionToken | MessageSubscription used to unsubscribing. |
Type Parameters
Name | Description |
---|---|
TMessage | Type of message. |
Unsubscribe<TMessage>(MessageHubSubscriptionToken)
Unsubscribe from a particular message type.
Does not throw an exception if the subscription is not found.
Declaration
void Unsubscribe<TMessage>(MessageHubSubscriptionToken subscriptionToken)
where TMessage : class, IMessageHubMessage
Parameters
Type | Name | Description |
---|---|---|
MessageHubSubscriptionToken | subscriptionToken | Subscription token received from Subscribe. |
Type Parameters
Name | Description |
---|---|
TMessage | Type of message. |