SignalR群体 ​​- 在客户端或服务器滤波处理? [英] SignalR groups - filtering handled on client or server?

查看:122
本文介绍了SignalR群体 ​​- 在客户端或服务器滤波处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关SignalR枢纽和团体像样的数目。特别是,我注意到,你不能在一个特定的群体获得的连接的计数。

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.

是在客户端或服务器上处理组过滤?如果服务器,为什么不能SignalR暴露计数?如果客户端上,有没有办法将消息发送给只有特定的客户呢?

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?

推荐答案

当您将消息发送到特定连接的特定组,筛选发生在服务器上(没有过滤功能,你只是解决了一个连接或一组)。

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是基于酒馆子,所以没有连接本身的列表。如果你想跟踪连接列表中,那么你必须处理连接和断开事件,并在内存中或某些持久性存储坚持他们。

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.

这篇关于SignalR群体 ​​- 在客户端或服务器滤波处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆