Does Azure SignalR All.SendAsync send messages to ALL clients, or just clients with given method name?

254 views Asked by At

Problem: To minimize per-message charges, I'd like to restrict messages by method name. Per the picture below, I need to know to which clients SignalR will send a message in the following case:

1.) Create Hub "/MyHub"

2.) 3 users (on Angular clients) register with the Hub, with a method named "Post_A"

3.) Then 2 different users register with the same Hub with a method named "Post_B"

4.) If the API server sends an update via Clients.All.SendAsync("post_B", dto) will it only go to users 3 & 4? Or will that message go to all five users?

Bonus! If the answer is that all messages go to all users, is there an option without using groups? I don't think groups will work w/o a lot of additional overhead each time a user views a new post (there will be thousands of posts).

Thank you!

enter image description here

1

There are 1 answers

0
Jason On BEST ANSWER

Did some testing.

SignalR's Clients.All.SendAsync(MethodName, object) does send a message to all clients, even if they haven't registered with the method MethodName.

enter image description here

As you can see in the client-side logs above (after turning on SignalR's logging to console), the client throws a warning when it receives a message for which it has no method registered.

So groups are the only option for restricting messages.