use*_*912 2 signalr signalr.client
如果我有一个 signalR 集线器,它向所有具有相当大的有效载荷或私人信息的客户端发送消息,那么所有连接到集线器(同一组的一部分)的客户端都会收到消息,即使它们没有订阅这些事件客户端?
想知道客户端是否足够聪明,可以协商它对服务器的哪些事件,以便服务器不会发送无关数据?
谢谢!
是的,他们这样做。如果客户端订阅了一个集线器,它将接收通过该集线器的广播频道发送的所有消息。
除了发送到不包含该客户端的特定组或专门发送到另一个客户端之外,没有办法阻止客户端获取消息。
一些例子:
Clients.All.foo(); // All subscribed clients will foo invoked
Clients.Group("bar").foo(); // All subscribed clients to the hubs group "Bar" will have foo invoked. If your client is not subscribed to "bar" it will not have "foo" invoked.
Clients.Client("AClientsConnectionId").foo(); // The client with the specified connection id will have foo invoked.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
234 次 |
| 最近记录: |