我如何遍历SignalR组(集线器类)Groups.Add(Context.ConnectionId, "foo");
我将如何遍历该小组以了解谁在其中?然后可能基于其中的connectionId返回一个用户
可能在客户端连接/断开/重新连接时实现字典
public static readonly ConcurrentDictionary<string, object> _connections
= new ConcurrentDictionary<string, object>();
public Task Connect()
{
_connections.TryAdd(Context.ConnectionId, null);
Groups.Add(Context.ConnectionId, "users");
//Returns Connection count.
return Clients.tally(_connections.Count.ToString());
}
您可以扩展此名称以包括名称或组等,但是就像akoeplinger所说的那样,您必须在整个应用程序中始终对此进行跟踪。