reach4thelasers
reach4thelasers

Reputation: 26909

SignalR - Sending a Message to a subset of users

I need to send updates via SignalR to a users "Friends", not all connected users.

Clients.callbackName()

Sends a message to All Connected Clients. How do I send a message to just a few clients?

Upvotes: 0

Views: 2584

Answers (2)

davidfowl
davidfowl

Reputation: 38764

You can specify the connection id or group name. Check out the docs for more info:

http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-server

Upvotes: 2

Will
Will

Reputation: 773

To add a client to a specific group...

Groups.Add(Context.ConnectionId, "johnsFriends");

To send a message to that clients group of friends...

Clients["johnsFriends"].addMessage(message);

Then on the client side the "addMessage" method will be invoked for all clients in the group "johnsFriends".

Upvotes: 1

Related Questions