-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Description
Is your feature request related to a problem? Please describe.
I am trying to send a SignalR Message to a List of Groups and Users. For example, all Admins and Managers should get this message as well as a certain user who triggered an API call in the program.
To do this we are using the following code.
[CapSubscribe(EventNames.SignalRUpdateEventName)]
public async Task Handle(SignalREvent @event)
{
//Adds a message ID to each message to give the client the option to discard duplicates
@event.JsonPayload.Add("MessageId", Guid.NewGuid().ToString());
if ([email protected]())
{
await _hubContext.Clients.Groups(@event.Groups).SendAsync(@event.MethodName, new object[] {@event.JsonPayload});
}
if ([email protected]())
{
await _hubContext.Clients.Users(@event.Users)
.SendAsync(@event.MethodName, new object[] {@event.JsonPayload});
}
}
This results in multiple Messages being sent by SignalR and our client receiving multiple messages if the user is, for example, the one who initiated the call and is part of the group Admin and Manager.
Describe the solution you'd like
My Solution would be that I could call something like this:
_hubContext.Clients.Groups(@event.Groups).Users(@event.Users).SendAsync(@event.MethodName, new object[] {@event.JsonPayload});
And in the background singalR would aggregate all the connection Ids so that only one message per connection would be sent.