You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/signalr/groups.md
+13-5Lines changed: 13 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,15 @@ description: Overview of ASP.NET Core SignalR User and Group management.
5
5
monikerRange: '>= aspnetcore-2.1'
6
6
ms.author: bradyg
7
7
ms.custom: mvc
8
-
ms.date: 05/17/2020
8
+
ms.date: 04/04/2024
9
9
uid: signalr/groups
10
10
---
11
11
12
12
# Manage users and groups in SignalR
13
13
14
14
By [Brennan Conroy](https://github.com/BrennanConroy)
15
15
16
-
SignalR allows messages to be sent to all connections associated with a specific user, as well as to named groups of connections.
16
+
SignalR allows messages to be sent to all connections associated with a specific user and to named groups of connections.
17
17
18
18
[View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/signalr/groups/sample/)[(how to download)](xref:index#how-to-download-a-sample)
19
19
@@ -32,13 +32,21 @@ Send a message to a specific user by passing the user identifier to the `User` f
32
32
33
33
## Groups in SignalR
34
34
35
-
A group is a collection of connections associated with a name. Messages can be sent to all connections in a group. Groups are the recommended way to send to a connection or multiple connections because the groups are managed by the application. A connection can be a member of multiple groups. Groups are ideal for something like a chat application, where each room can be represented as a group. Connections are added to or removed from groups via the `AddToGroupAsync` and `RemoveFromGroupAsync` methods.
35
+
A group is a collection of connections associated with a name. Messages can be sent to all connections in a group. Groups are the recommended way to send to a connection or multiple connections because the groups are managed by the application. A connection can be a member of multiple groups. Groups are ideal for something like a chat application, where each room can be represented as a group.
36
+
37
+
### Add or remove connections from a group
38
+
39
+
Connections are added to or removed from groups via the `AddToGroupAsync` and `RemoveFromGroupAsync` methods:
Group membership isn't preserved when a connection reconnects. The connection needs to rejoin the group when it's re-established. It's not possible to count the members of a group, since this information is not available if the application is scaled to multiple servers.
43
+
It's safe to add a user to a group multiple times, no exception is thrown in the case that the user already exists in the group.
44
+
45
+
Group membership isn't preserved when a connection reconnects. The connection needs to rejoin the group when it's re-established. It's not possible to count the members of a group, since this information isn't available if the application is scaled to multiple servers.
46
+
47
+
Groups are kept in memory, so they won't persist through a server restart. Consider the Azure SignalR service for scenarios requiring group membership to be persisted. For more information, see [Azure SignalR](/azure/azure-signalr/signalr-overview)
40
48
41
-
To protect access to resources while using groups, use [authentication and authorization](xref:signalr/authn-and-authz) functionality in ASP.NET Core. If a user is added to a group only when the credentials are valid for that group, messages sent to that group will only go to authorized users. However, groups are not a security feature. Authentication claims have features that groups do not, such as expiry and revocation. If a user's permission to access the group is revoked, the app must remove the user from the group explicitly.
49
+
To protect access to resources while using groups, use [authentication and authorization](xref:signalr/authn-and-authz) functionality in ASP.NET Core. If a user is added to a group only when the credentials are valid for that group, messages sent to that group will only go to authorized users. However, groups are not a security feature. Authentication claims have features that groups don't, such as expiry and revocation. If a user's permission to access the group is revoked, the app must remove the user from the group explicitly.
0 commit comments