

We can send messages to all connections in a group using the group name. Only then can the connections be mapped to specific users.Ī SignalR group is a collection of connections associated with a name. However, sending messages to individual users requires our application to authenticate users and set the NameIdentifier claim in ClaimsPrincipal.

Remember that when we are sending messages to a user, they will be sent to all connections associated with that user and not just any particular connection. => await Clients.User(userId).SendAsync("broadcasttouser", data) We can send messages to a particular user using this value: public async Task BroadcastToUser(string data, string userId) => await Clients.Client(connectionId).SendAsync("broadcasttoclient", data) īy default, SignalR uses the ClaimTypes.NameIdentifier from the ClaimsPrincipal associated with the connection as the user identifier. Public async Task BroadcastToConnection(string data, string connectionId)
