// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace Microsoft.AspNetCore.SignalR { /// /// A lifetime manager abstraction for instances. /// public abstract class HubLifetimeManager where THub : Hub { // Called by the framework and not something we'd cancel, so it doesn't take a cancellation token /// /// Called when a connection is started. /// /// The connection. /// A that represents the asynchronous connect. public abstract Task OnConnectedAsync(HubConnectionContext connection); // Called by the framework and not something we'd cancel, so it doesn't take a cancellation token /// /// Called when a connection is finished. /// /// The connection. /// A that represents the asynchronous disconnect. public abstract Task OnDisconnectedAsync(HubConnectionContext connection); /// /// Sends an invocation message to all hub connections. /// /// The invocation method name. /// The invocation arguments. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous send. public abstract Task SendAllAsync(string methodName, object[] args, CancellationToken cancellationToken = default); /// /// Sends an invocation message to all hub connections excluding the specified connections. /// /// The invocation method name. /// The invocation arguments. /// A collection of connection IDs to exclude. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous send. public abstract Task SendAllExceptAsync(string methodName, object[] args, IReadOnlyList excludedConnectionIds, CancellationToken cancellationToken = default); /// /// Sends an invocation message to the specified connection. /// /// The connection ID. /// The invocation method name. /// The invocation arguments. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous send. public abstract Task SendConnectionAsync(string connectionId, string methodName, object[] args, CancellationToken cancellationToken = default); /// /// Sends an invocation message to the specified connections. /// /// The connection IDs. /// The invocation method name. /// The invocation arguments. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous send. public abstract Task SendConnectionsAsync(IReadOnlyList connectionIds, string methodName, object[] args, CancellationToken cancellationToken = default); /// /// Sends an invocation message to the specified group. /// /// The group name. /// The invocation method name. /// The invocation arguments. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous send. public abstract Task SendGroupAsync(string groupName, string methodName, object[] args, CancellationToken cancellationToken = default); /// /// Sends an invocation message to the specified groups. /// /// The group names. /// The invocation method name. /// The invocation arguments. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous send. public abstract Task SendGroupsAsync(IReadOnlyList groupNames, string methodName, object[] args, CancellationToken cancellationToken = default); /// /// Sends an invocation message to the specified group excluding the specified connections. /// /// The group name. /// The invocation method name. /// The invocation arguments. /// A collection of connection IDs to exclude. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous send. public abstract Task SendGroupExceptAsync(string groupName, string methodName, object[] args, IReadOnlyList excludedConnectionIds, CancellationToken cancellationToken = default); /// /// Sends an invocation message to the specified user. /// /// The user ID. /// The invocation method name. /// The invocation arguments. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous send. public abstract Task SendUserAsync(string userId, string methodName, object[] args, CancellationToken cancellationToken = default); /// /// Sends an invocation message to the specified users. /// /// The user IDs. /// The invocation method name. /// The invocation arguments. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous send. public abstract Task SendUsersAsync(IReadOnlyList userIds, string methodName, object[] args, CancellationToken cancellationToken = default); /// /// Adds a connection to the specified group. /// /// The connection ID to add to a group. /// The group name. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous add. public abstract Task AddToGroupAsync(string connectionId, string groupName, CancellationToken cancellationToken = default); /// /// Removes a connection from the specified group. /// /// The connection ID to remove from a group. /// The group name. /// The token to monitor for cancellation requests. The default value is . /// A that represents the asynchronous remove. public abstract Task RemoveFromGroupAsync(string connectionId, string groupName, CancellationToken cancellationToken = default); } }