Class NatsHubLifetimeManager<THub>
The NATS scaleout provider for multi-server support.
Namespace: Neon.SignalR
Assembly: Neon.SignalR.dll
Syntax
public class NatsHubLifetimeManager<THub> : HubLifetimeManager<THub> where THub : Hub
Type Parameters
Name | Description |
---|---|
THub | The type of Hub to manage connections for. |
Constructors
NatsHubLifetimeManager(NatsConnection, AsyncKeyedLocker<string>)
Constructs the NatsHubLifetimeManager<THub> with types from Dependency Injection.
Declaration
public NatsHubLifetimeManager(NatsConnection connection, AsyncKeyedLocker<string> lockProvider)
Parameters
Type | Name | Description |
---|---|---|
NatsConnection | connection | The NATS NATS.Client.Core.NatsConnection. |
AsyncKeyedLocker<string> | lockProvider | Async lock provider. |
NatsHubLifetimeManager(NatsConnection, AsyncKeyedLocker<string>, ILoggerFactory)
Constructs the NatsHubLifetimeManager<THub> with types from Dependency Injection.
Declaration
public NatsHubLifetimeManager(NatsConnection connection, AsyncKeyedLocker<string> lockProvider, ILoggerFactory loggerFactory = null)
Parameters
Type | Name | Description |
---|---|---|
NatsConnection | connection | The NATS NATS.Client.Core.NatsConnection. |
AsyncKeyedLocker<string> | lockProvider | Async lock provider. |
ILoggerFactory | loggerFactory | The logger factory. |
Methods
AddToGroupAsync(string, string, CancellationToken)
Adds a connection to the specified group.
Declaration
public override Task AddToGroupAsync(string connectionId, string groupName, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | connectionId | The connection ID to add to a group. |
string | groupName | The group name. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous add. |
Overrides
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
Declaration
public ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask | A task that represents the asynchronous dispose operation. |
OnConnectedAsync(HubConnectionContext)
Called when a connection is started.
Declaration
public override Task OnConnectedAsync(HubConnectionContext connection)
Parameters
Type | Name | Description |
---|---|---|
HubConnectionContext | connection | The connection. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous connect. |
Overrides
OnDisconnectedAsync(HubConnectionContext)
Called when a connection is finished.
Declaration
public override Task OnDisconnectedAsync(HubConnectionContext connection)
Parameters
Type | Name | Description |
---|---|---|
HubConnectionContext | connection | The connection. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous disconnect. |
Overrides
RemoveFromGroupAsync(string, string, CancellationToken)
Removes a connection from the specified group.
Declaration
public override Task RemoveFromGroupAsync(string connectionId, string groupName, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | connectionId | The connection ID to remove from a group. |
string | groupName | The group name. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous remove. |
Overrides
SendAllAsync(string, object[], CancellationToken)
Sends an invocation message to all hub connections.
Declaration
public override Task SendAllAsync(string methodName, object[] args, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | methodName | The invocation method name. |
object[] | args | The invocation arguments. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous send. |
Overrides
SendAllExceptAsync(string, object[], IReadOnlyList<string>, CancellationToken)
Sends an invocation message to all hub connections excluding the specified connections.
Declaration
public override Task SendAllExceptAsync(string methodName, object[] args, IReadOnlyList<string> excludedConnectionIds, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | methodName | The invocation method name. |
object[] | args | The invocation arguments. |
IReadOnlyList<string> | excludedConnectionIds | A collection of connection IDs to exclude. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous send. |
Overrides
SendConnectionAsync(string, string, object[], CancellationToken)
Sends an invocation message to the specified connection.
Declaration
public override Task SendConnectionAsync(string connectionId, string methodName, object[] args, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | connectionId | The connection ID. |
string | methodName | The invocation method name. |
object[] | args | The invocation arguments. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous send. |
Overrides
SendConnectionsAsync(IReadOnlyList<string>, string, object[], CancellationToken)
Sends an invocation message to the specified connections.
Declaration
public override Task SendConnectionsAsync(IReadOnlyList<string> connectionIds, string methodName, object[] args, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<string> | connectionIds | The connection IDs. |
string | methodName | The invocation method name. |
object[] | args | The invocation arguments. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous send. |
Overrides
SendGroupAsync(string, string, object[], CancellationToken)
Sends an invocation message to the specified group.
Declaration
public override Task SendGroupAsync(string groupName, string methodName, object[] args, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | groupName | The group name. |
string | methodName | The invocation method name. |
object[] | args | The invocation arguments. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous send. |
Overrides
SendGroupExceptAsync(string, string, object[], IReadOnlyList<string>, CancellationToken)
Sends an invocation message to the specified group excluding the specified connections.
Declaration
public override Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList<string> excludedConnectionIds, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | groupName | The group name. |
string | methodName | The invocation method name. |
object[] | args | The invocation arguments. |
IReadOnlyList<string> | excludedConnectionIds | A collection of connection IDs to exclude. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous send. |
Overrides
SendGroupsAsync(IReadOnlyList<string>, string, object[], CancellationToken)
Sends an invocation message to the specified groups.
Declaration
public override Task SendGroupsAsync(IReadOnlyList<string> groupNames, string methodName, object[] args, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<string> | groupNames | The group names. |
string | methodName | The invocation method name. |
object[] | args | The invocation arguments. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous send. |
Overrides
SendUserAsync(string, string, object[], CancellationToken)
Sends an invocation message to the specified user.
Declaration
public override Task SendUserAsync(string userId, string methodName, object[] args, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userId | The user ID. |
string | methodName | The invocation method name. |
object[] | args | The invocation arguments. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous send. |
Overrides
SendUsersAsync(IReadOnlyList<string>, string, object[], CancellationToken)
Sends an invocation message to the specified users.
Declaration
public override Task SendUsersAsync(IReadOnlyList<string> userIds, string methodName, object[] args, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<string> | userIds | The user IDs. |
string | methodName | The invocation method name. |
object[] | args | The invocation arguments. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task | A Task that represents the asynchronous send. |