XMPP多用户聊天获取用户列表
获取所有用户的列表以及 XMPP 多用户聊天的状态 我这样
<iq from='[email protected]/pda'
id='kl2fax27'
to='[email protected]'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
做得到了一个列表,但没有状态。 我需要让状态上的所有用户都知道吗?
get a list of all users and the status of XMPP multi-user-chat
I do so
<iq from='[email protected]/pda'
id='kl2fax27'
to='[email protected]'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
getting a list but without status.
I need for all users on the statuses to know?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请阅读 XEP-0045,它描述了多用户聊天 (MUC) 协议。您需要加入房间:
然后您将从房间的每个占用者那里获得一个存在节及其当前状态:
在您询问之前,不,没有办法知道您何时“完成”接收这些通知,因为用户可能随时来来去去。您现在已订阅占用者的存在变化,并且必须跟踪接收方的当前状态。
Please read XEP-0045, which describes the multi-user chat (MUC) protocol. You need to join the room:
You'll then get a presence stanza from each occupant of the room with their current status:
And before you ask, no, there is no way to tell when you're "done" receiving these notifications, since users may come and go at any time. You are now subscribed to the presence changes of the occupants, and have to keep track of what is current on the receiving side.
通读 XMPP RFC,我发现状态是通过状态消息传达的,并且您询问另一个实体现在通过发送
探测
状态请求来报告其状态(而不是等待它在广播中告诉您),您将获得定向响应(<一个href="http://xmpp.org/rfcs/rfc3921.html#rfc.section.5.5" rel="nofollow">RFC 的§5.5 给出了一些示例)。当然,这取决于你能否正确解释他们所说的话……Reading through the XMPP RFC, I see that statuses are conveyed by presence messages, and that you ask another entity to report its status now (rather than waiting for it to tell you in a broadcast) by sending a
probe
status request to which you'll get a directed response (§5.5 of the RFC gives some examples). It's up to you to interpret what they say back correctly, of course…