Table of Contents

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

T

The 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

hubContext IHubContext<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

message T

The message to broadcast to all clients.

cancellationToken CancellationToken

A 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.