Using a SignalR hub clients can be added or removed from a group. A client can belong to multiple groups. Is it possible to remove a client from every group it currently bel
Looks like they have yet to implement this, but it is considered a candidate for v3. A feature request with the following code exists at https://github.com/SignalR/SignalR/issues/66
public static class SignalRConnectionToGroupsMap
{
private static readonly ConcurrentDictionary> Map = new ConcurrentDictionary>();
public static bool TryAddGroup(string connectionId, string groupName)
{
List groups;
if (!Map.TryGetValue(connectionId, out groups))
{
return Map.TryAdd(connectionId, new List() {groupName});
}
if (!groups.Contains(groupName))
{
groups.Add(groupName);
}
return true;
}
// since for this use case we will only want to get the List of group names
// when we're removing the mapping - we might as well remove the mapping while
// we're grabbing the List
public static bool TryRemoveConnection(string connectionId, out List result)
{
return Map.TryRemove(connectionId, out result);
}
}