/// <inheritdoc /> public override Task SendGroupsAsync(IReadOnlyList <string> groupNames, string methodName, object?[] args, CancellationToken cancellationToken = default) { // Each task represents the list of tasks for each of the writes within a group List <Task>? tasks = null; SerializedHubMessage?message = null; foreach (var groupName in groupNames) { if (string.IsNullOrEmpty(groupName)) { throw new InvalidOperationException("Cannot send to an empty group name."); } var group = _groups[groupName]; if (group != null) { DefaultHubLifetimeManager <THub> .SendToGroupConnections(methodName, args, group, null, null, ref tasks, ref message, cancellationToken); } } if (tasks != null) { return(Task.WhenAll(tasks)); } return(Task.CompletedTask); }
/// <inheritdoc /> public override Task SendGroupAsync(string groupName, string methodName, object?[] args, CancellationToken cancellationToken = default) { if (groupName == null) { throw new ArgumentNullException(nameof(groupName)); } var group = _groups[groupName]; if (group != null) { // Can't optimize for sending to a single connection in a group because // group might be modified inbetween checking and sending List <Task>? tasks = null; SerializedHubMessage?message = null; DefaultHubLifetimeManager <THub> .SendToGroupConnections(methodName, args, group, null, null, ref tasks, ref message, cancellationToken); if (tasks != null) { return(Task.WhenAll(tasks)); } } return(Task.CompletedTask); }
/// <inheritdoc /> public override Task SendGroupExceptAsync(string groupName, string methodName, object?[] args, IReadOnlyList <string> excludedConnectionIds, CancellationToken cancellationToken = default) { if (groupName == null) { throw new ArgumentNullException(nameof(groupName)); } var group = _groups[groupName]; if (group != null) { List <Task>? tasks = null; SerializedHubMessage?message = null; DefaultHubLifetimeManager <THub> .SendToGroupConnections(methodName, args, group, (connection, state) => !((IReadOnlyList <string>)state !).Contains(connection.ConnectionId), excludedConnectionIds, ref tasks, ref message, cancellationToken); if (tasks != null) { return(Task.WhenAll(tasks)); } } return(Task.CompletedTask); }