Class AzureSignalRReceiver<T>
- Assembly
- NuvTools.Notification.Realtime.Azure.SignalR.Client.dll
SignalR client for receiving real-time messages from an Azure SignalR hub with debouncing support.
public class AzureSignalRReceiver<T> : IDisposable
Type Parameters
TThe type of message to receive.
- Inheritance
-
AzureSignalRReceiver<T>
- Implements
- Inherited Members
Remarks
This receiver establishes a connection to a SignalR hub and listens for messages of type T.
It includes built-in debouncing to prevent rapid-fire message handling and supports automatic reconnection.
The receiver listens for messages on a method named "Consume_{TypeName}" where {TypeName} is the name of type T.
Constructors
AzureSignalRReceiver(string)
SignalR client for receiving real-time messages from an Azure SignalR hub with debouncing support.
public AzureSignalRReceiver(string url)
Parameters
urlstringThe URL of the SignalR hub to connect to.
Remarks
This receiver establishes a connection to a SignalR hub and listens for messages of type T.
It includes built-in debouncing to prevent rapid-fire message handling and supports automatic reconnection.
The receiver listens for messages on a method named "Consume_{TypeName}" where {TypeName} is the name of type T.
Properties
DebounceDelay
Gets or sets the debounce delay to prevent rapid-fire message handling. Default is 1000 milliseconds (1 second).
public TimeSpan DebounceDelay { get; set; }
Property Value
Remarks
When multiple messages arrive in quick succession, only the last message within the debounce window will trigger the MessageReceived event.
Methods
ConnectAsync()
Establishes a connection to the SignalR hub and starts listening for messages.
public Task ConnectAsync()
Returns
- Task
A task representing the asynchronous connect operation.
Remarks
If already connected, this method returns immediately without creating a new connection. The connection is configured with automatic reconnection enabled. Messages are received on a method named "Consume_{TypeName}".
DisconnectAsync()
Disconnects from the SignalR hub and disposes the connection.
public Task DisconnectAsync()
Returns
- Task
A task representing the asynchronous disconnect operation.
Remarks
This method also cancels any pending debounce operations.
Dispose()
Disposes the receiver, disconnecting from the hub and releasing all resources.
public void Dispose()
Remarks
This method cancels any pending debounce operations and synchronously disposes the hub connection.
Events
MessageReceived
Event raised when a message is received after the debounce delay has elapsed.
public event Action<T, CancellationToken>? MessageReceived