public async IAsyncEnumerable ListConnectionsInGroupAsync()

in src/Microsoft.Azure.SignalR.Common/ServiceConnections/MultiEndpointMessageWriter.cs [177:213]


    public async IAsyncEnumerable<GroupMember> ListConnectionsInGroupAsync(string groupName, int? top = null, ulong? tracingId = null, [EnumeratorCancellation] CancellationToken token = default)
    {
        if (TargetEndpoints.Length == 0)
        {
            Log.NoEndpointRouted(_logger, nameof(GroupMemberQueryMessage));
            yield break;
        }
        if (top <= 0)
        {
            throw new ArgumentOutOfRangeException(nameof(top), "Top must be greater than 0.");
        }
        foreach (var endpoint in TargetEndpoints)
        {
            IAsyncEnumerable<GroupMember> enumerable;
            try
            {
                enumerable = endpoint.ConnectionContainer.ListConnectionsInGroupAsync(groupName, top, tracingId, token);
            }
            catch (ServiceConnectionNotActiveException)
            {
                Log.FailedWritingMessageToEndpoint(_logger, nameof(GroupMemberQueryMessage), null, endpoint.ToString());
                continue;
            }
            await foreach (var member in enumerable)
            {
                yield return member;
                if (top.HasValue)
                {
                    top--;
                    if (top == 0)
                    {
                        yield break;
                    }
                }
            }
        }
    }