SignalR groups - filtering handled on client or server?

二次信任 提交于 2019-12-04 16:50:21

问题


I've been reading a decent amount regarding SignalR hubs and groups. In particular, I've noticed that you cannot get a count of the connections in a particular group.

Is the filtering for groups handled on the client or server? If the server, why can't SignalR expose a count? If on the client, is there a way to send messages only to particular clients?


回答1:


When you send a message to a particular group of specific connection, filtering happens on the server (there's no filtering, you're just addressing that one connection or group).

SignalR is based on pub sub so there's no list of connections per se. If you want to keep track of a list of connections then you have to handle the connection and disconnect events and persist them in memory or some persistent storage.

The reason we don't give you a list of connections is because any state we store hurts scaling out across nodes. If we gave you a list of connections, it's a pit of failure, because if you add another web node to your farm, you suddenly have to synchronize state across it. We let you address individual connections or groups via their identifier and that allows us to use the message bus to publish to all subscribers of that identifier.



来源:https://stackoverflow.com/questions/11143220/signalr-groups-filtering-handled-on-client-or-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!