如何获取特定SignalR Core组中的连接数?
像这样的东西:
this.Clients.Group("Something").Count();
如果 SendAsync
将返回多少客户端发送消息也会很好:
var count = await this.Clients.Client(this.Context.ConnectionId).SendAsync("msg", msg);
我需要这个来确定组是否为空 . 如果用户用力断开SignalR Core(拔下网线),数据应该是正确的......
1 回答
您可以使用OnConnected和OnDisconnected事件并保存连接/ connectionIds .
我使用类似的东西和其他信息: