dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.15k stars 9.92k forks source link

Add a `SendInAllGroups(string group1, string group2)` #16908

Open aateeque opened 4 years ago

aateeque commented 4 years ago

It would be really useful to have an And like operator on groups where you can send a message to clients in a number of groups: user intersection in groups. Maybe useful to expose HubGroupList to allow richer linq statements

BrennanConroy commented 4 years ago

We have await Clients.Groups(group1, group2, etc...).SendAsync(...); already. https://source.dot.net/#Microsoft.AspNetCore.SignalR.Core/IHubClients%2560T.cs,d37e9b653646baf5

aateeque commented 4 years ago

I meant more like send to Client if Client is in group1 AND group2; from the doc on that method it's for all clients in all groups given.

analogrelay commented 4 years ago

Maybe useful to expose HubGroupList to allow richer linq statements

That only works when you have a single server though. As soon as you have Azure SignalR or Redis in place, there is no one list of group members.

It would be really useful to have an And like operator on groups where you can send a message to clients in a number of groups: user intersection in groups.

We never had this in ASP.NET SignalR (that I'm aware of). Generally the pattern we recommended was for you to create intersection groups yourself if you need them. Adding new "addresses" like this is quite costly since it requires updates and support across scale-out systems (Redis and Azure SignalR).

In particularly, this one is challenging because we implement groups using Redis channels and there's no way to do intersection there. We'd have to implement intersection on each server, which is costly.

Given the history here, I don't think this is a high priority for us, at least not without more customer feedback.