Interface IUserConnectionManager
A manager that tracks connection ids for users.
Namespace: Umbraco.Cms.Core.ServerEvents
Assembly: Umbraco.Core.dll
Syntax
public interface IUserConnectionManager
Methods
View SourceAddConnection(Guid, string)
Add a connection to a user.
Declaration
void AddConnection(Guid userKey, string connectionId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | userKey | The key of the user to add the connection to. |
| string | connectionId | Connection id to add. |
GetConnections(Guid)
Get all connections held by a user.
Declaration
ISet<string> GetConnections(Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | userKey | The key of the user to get connections for. |
Returns
| Type | Description |
|---|---|
| ISet<string> | The users connections. |
GetConnectionsAuthorizedFor(string)
Gets the connections whose user is authorized for the given event source, keyed by user.
Declaration
IReadOnlyDictionary<Guid, IReadOnlyCollection<string>> GetConnectionsAuthorizedFor(string eventSource)
Parameters
| Type | Name | Description |
|---|---|---|
| string | eventSource | The event source to filter by. |
Returns
| Type | Description |
|---|---|
| IReadOnlyDictionary<Guid, IReadOnlyCollection<string>> | A snapshot mapping each authorized user's key to their current connection ids. |
Remarks
Returning an empty snapshot here would masquerade as "nobody authorized" and silently drop entity-scoped server events, so this default throws instead — implementations of IUserConnectionManager must override it.
RemoveConnection(Guid, string)
Removes a connection from a user.
Declaration
void RemoveConnection(Guid userKey, string connectionId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | userKey | The user key to remove the connection from. |
| string | connectionId | The connection id to remove |
SetAuthorizedEventSources(Guid, IEnumerable<string>)
Records the event sources a user is authorized for, as determined at connect time. This is the authorization consulted when routing entity-scoped events by connection id (as opposed to the SignalR group broadcast).
Declaration
void SetAuthorizedEventSources(Guid userKey, IEnumerable<string> eventSources)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | userKey | The key of the user. |
| IEnumerable<string> | eventSources | The event sources the user is authorized for. |
Remarks
The default is a no-op so a custom implementation that does not track this still connects; such an implementation must also override GetConnectionsAuthorizedFor(string) for entity-scoped events to be delivered.