Class AzureSignalRSender<T>
- Namespace
- NuvTools.Notification.Realtime.Azure.SignalR
- Assembly
- NuvTools.Notification.Realtime.Azure.SignalR.dll
Azure SignalR implementation of IMessageSender<T> for broadcasting real-time messages to all connected clients.
public class AzureSignalRSender<T> : IMessageSender<T> where T : class
Type Parameters
TThe type of message to send. Must be a reference type.
- Inheritance
-
AzureSignalRSender<T>
- Implements
- Inherited Members
Remarks
This sender broadcasts messages to all connected clients using a method name pattern of "Consume_{TypeName}". Clients must register a handler for this method name to receive messages.
Constructors
AzureSignalRSender(IHubContext<SignalRHub>)
Azure SignalR implementation of IMessageSender<T> for broadcasting real-time messages to all connected clients.
public AzureSignalRSender(IHubContext<SignalRHub> hubContext)
Parameters
hubContextIHubContext<SignalRHub>The SignalR hub context used to send messages to clients.
Remarks
This sender broadcasts messages to all connected clients using a method name pattern of "Consume_{TypeName}". Clients must register a handler for this method name to receive messages.
Methods
SendAsync(T, CancellationToken)
Sends a message asynchronously to all connected SignalR clients.
public Task SendAsync(T message, CancellationToken cancellationToken)
Parameters
messageTThe message to broadcast to all clients.
cancellationTokenCancellationTokenA token to observe while waiting for the operation to complete.
Returns
- Task
A task representing the asynchronous send operation.
Remarks
The message is sent using the method name "Consume_{TypeName}" where {TypeName} is the name of type T.
All connected clients that have registered a handler for this method will receive the message.