使用 xmpp 进行实时通知

发布于 2024-09-17 11:28:44 字数 434 浏览 5 评论 0原文

我希望使用 xmpp 在我的应用程序中包含两个功能。第一个是几乎完成的一对一聊天(使用 strope),第二个是实时通知,就像 Facebook 中的工作方式一样。我尝试了解 xmpp 中的 pubsub 系统,但认为它不适合这个特定问题。如有错误请指正,可能是概念理解不正确造成的。 我的要求是这样的—— 任何用户都可以触发预定义的事件,当其中一个用户触发时,在线的其他人应该收到相同的通知。此外,我还想在发送通知之前检查用户是否愿意接收通知。我在这里不明白的是,如果要使用 pubsub,节点在哪里以及如何适合。我可以只创建一个节点,让其他节点订阅吗?在这种情况下,订阅者如何在不是节点所有者的情况下在其上发布事件?

我正在考虑的另一种方法是使用标题类型或附加有效负载(例如 )将消息逐一发送给所有用户的 jids,以将其与普通消息区分开来。考虑到可扩展性,这种方法可以吗?

I am looking to include two features in my app using xmpp. The first one is a one-to-one chat which is almost complete (using strophe) and the second one is real time notifications just the way it works in facebook. I tried to understand the pubsub system in xmpp but dont feel that it will suit this particular problem. Please correct if wrong, it might be due to not getting the concepts correctly.
My requirement is this -
There will be predefined events that any of the users can fire and when one does, the others who are online should receive a notification for the same. Further i would also want to check if the user has preferred to receive notifications or not before sending them. What I am not getting here is if pubsub is to be used, where and how do the nodes fit. Can I create just one node which every one else will subscribe to ? In that case how will the subscribers publish their events on it without being the node owner ?

The other method I am thinking of is to send message to the jids of all users one by one with a headline type or with an additional payload say <notif/> for differentiating it from normal messages. Is this method fine taking scalability in to account ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

百变从容 2024-09-24 11:28:45

PubSub 可以工作,但是,您所描述的感觉更像是 MUC (多用户聊天)。

基本上,它创建一个您的访问者可以加入的聊天室(也许不使用这种措辞),然后,好吧,当其中任何一个人感知到聊天室的消息时,所有人都会得到它。您当然可以进行配置,只允许某些用户发布。

由于您已经有一个在浏览器上运行的客户端(使用 Strope),所以这应该相当容易。只需确保此MUC 组件正在您的服务器上运行即可。

PubSub would work, however, what you describes feels more like MUC (Multi User Chat).

Basically, it creates a chatroom that your visitors can join (maybe not using this verbiage), and then, well, when any of them sens a message to the chat room, all of them get it. You can certainly have configuration where you only allow certain users to publish.

Since you already have a client running on the browser, with Strophe, it should be fairly easy. Just make sure this MUC component is running on your server.

瞳孔里扚悲伤 2024-09-24 11:28:45

您尝试使用 xmpphp 库执行的操作(即在需要时向多个 jid 发送消息)是 pub-sub 或 MUC 可以为您做的事情。 :D 因此,根据您的应用程序类型,您需要选择一种并继续尝试 xmpp,随着您的继续,事情应该会变得清晰......

what you are trying to do with xmpphp library, i.e. sending message to multiple jid's when required, is what pub-sub or MUC can do for you. :D Hence depending upon your application type you need to choose one and go ahead experimenting with xmpp, things should get clear as you proceed....

凡尘雨 2024-09-24 11:28:45

要回答有关实时通知的第二个问题,您需要使用 PEP 而不是 pubsub。两者之间的主要区别在于 PEP 只会发布给您名册中的那些是我想你想要的。此外,我认为 PEP 比 pubsub 得到更广泛的支持,或者至少 jabber.org 支持它。 PEP 的唯一问题是它需要实体功能支持。

我在此处写了关于它的博客。 Java 中的示例;希望你不反对它;-)

To answer your second question regarding realtime notification, what you need is use PEP instead of pubsub. The main difference between the 2 is that PEP will only publish to those in your roster which is I think what you want. Furthermore I think PEP is more widely supported than pubsub or atleast jabber.org supports it. The only problem with PEP is that it requires Entity Capability support.

I've blogged about it here. Examples are in Java; hope you are not adverse to it ;-)

绝情姑娘 2024-09-24 11:28:45

对于这种情况,Pubsub 是一个合适的解决方案。据我所知,它可以满足您的所有要求。如果您希望用户对每种消息类型进行不同的订阅,您将需要为每种事件类型设置一个节点(或者可以在单个节点上使用过滤器,但我认为多个节点更容易)。节点所有者可以允许任何人发布到节点,因此这不是问题。

提到了 PEP,但如果您想发布给不在您名册中的用户,那么这不是正确的解决方案。

Pubsub 还允许您定义消息所需的任何内容类型,或者如果消息传输的简单行为已提供足够的信息,则根本不定义任何内容类型。

Pubsub would be an appropriate solution for this case. It handles all your requirements from what I can see. You will need to set up a node for each event type, if you expect to have users subscribe differently for each message type (alternatively filters can be used on a single node, but I think multiple nodes are easier). The node owner can allow anyone to publish to a node, so that is not an issue.

PEP was mentioned, but is not the right solution if you want to publish to users that are not in your roster.

Pubsub will also allow you to define any content type you want for messages or none at all if the simple act of the message transmission is informative enough.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文