2

I adding members to a SignalR group in an Azure function with SignalR binding like this:

await signalRGroupActions.AddAsync(
    new SignalRGroupAction
    {
        ConnectionId = message.ConnectionId,
        UserId = message.Recipient,
        GroupName = message.CurrentGroupName,
        Action = GroupAction.Add
    }
);

But How can I get the list of group members and their details i.e., UserId, ConnectionId etc?

Muzaffar Mahmood
  • 1,688
  • 2
  • 17
  • 20
  • 1
    maybe we need to store the group membership in somewhere else? https://learn.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/working-with-groups#storing-group-membership-in-a-database – Tiny Wang Aug 01 '23 at 09:04

1 Answers1

2

Like the document shared by @Tiny Wang in the comments, the same is try for the ASP.NET Core version of SignalR as well. The service itself does not keep track of group membership information and doesn't re-join users on reconnects.

Instead, you should implement your own persistence layer that keeps track of this information. With this, you have complete control over how you get group, member, and connection details from your database.

PramodValavala
  • 6,026
  • 1
  • 11
  • 30
  • Thank you PramodValavala! You are right we are to manage it ourselves on every add, remove members in the groups, connection start, and connection close everything. – Muzaffar Mahmood Aug 02 '23 at 12:53