当用户订阅机器人时,应该如何处理发送 xmpp 欢迎消息(一般情况)
正如标题所示,我想在用户订阅机器人时发送一条欢迎消息。
然而,据我了解,存在订阅节不应包含包含资源的 from-JID(我对 Adium 的测试表明情况也是如此)。也就是说,欢迎消息可以轻松发送到裸 JID,但这真的是正确的方法吗?感觉应该将其发送到订阅发起的实际实例。
也许我看到了一个根本不存在的问题?如果没有,有什么解决办法的想法吗?
As the title says, I would like to send a welcome message when a user subscribes to a bot.
However, as I understand it, presence subscribe stanzas should not contain a from-JID that includes resource (and my testing with Adium indicates that is also the case). That is, welcome message could easily be sent to the bare JID but is that really the right way to do it? It feels like it should be sent to the actual instance where the subscription originated.
Perhaps I'm seeing a problem where there is none? If not, any ideas on how to solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要害怕向裸 JID 发送消息。几乎所有时候这都是你想要的。用户可能已经拥有一个出色的系统,使用优先级在正确的设备上获取答案,例如黑莓、他们的家庭 jabber 客户端、工作中的客户端等。哎呀,他们可能已经从优先级为 0 的黑莓发送了请求,并且他们希望在办公桌上得到答案。
只需发送带有标题类型的消息节,因为您不希望他们回复通知。
Do not fear sending a message to a bare JID. Almost all the time this is what you want. The user may already have a fantastic system in place using priority to get the answer at the right device, like a blackberry, their home jabber client, the one at work, and so on. Heck, they may have sent the request from their blackberry that has a 0 priority, and they want to get the answer back at their desk.
Just send a message stanza with a type of headline, since you don't want them to reply to the notice.
关于消息的事情说得都对。
如果你关心向谁发送存在订阅节,我想知道你当时是否真的了解资源。 IIRC,在转发存在订阅之前资源被剥夺,我假设您正在响应它们。此外,机器人希望了解所有存在,因此订阅 bare jid 是正确的做法。
The things said about messages are all right.
If you care about whom to send presence subscribe stanzas to, I wonder whether you really know resources at that time. IIRC, resources are stripped off before forwarding presence subscribes and I assume that you are responding to them. Furthermore, the bot wants to be informed about all presences, so subscribing to the bare jid is the right thing to do.