A SignalR message can be sent to any of the following:
- All: All connected clients will receive it
- Group: Only clients in a certain group will receive it; groups are identified by a name
- Group Except: All clients in a certain group except certain clients, identified by their connection IDs
- Client: Only a specific client, identified by its connection ID
Clients are identified by a connection ID, that can be obtained from the Context property of the Hubclass:
var connectionId = this.Context.ConnectionId;
Users can be added to any number of groups (and removed as well, of course):
await this.Groups.AddAsync(this.Context.ConnectionId, "MyFriends");
await this.Groups.RemoveAsync(this.Connection.ConnectionId, "MyExFriends");
To send a message to a group, replace the All property by a Group call:
await this.Clients.Group("MyFriends...