XMPP多用户聊天获取用户列表

发布于 2024-11-19 03:34:26 字数 584 浏览 3 评论 0原文

获取所有用户的列表以及 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 技术交流群。

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

发布评论

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

评论(2

梦魇绽荼蘼 2024-11-26 03:34:26

请阅读 XEP-0045,它描述了多用户聊天 (MUC) 协议。您需要加入房间:

<presence
    from='[email protected]/pda'
    to='[email protected]/thirdwitch'>
  <x xmlns='http://jabber.org/protocol/muc'/>
</presence>

然后您将从房间的每个占用者那里获得一个存在节及其当前状态:

<presence
    from='[email protected]/firstwitch'
    to='[email protected]/pda'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='owner' role='moderator'/>
  </x>
</presence>

<presence
    from='[email protected]/secondwitch'
    to='[email protected]/pda'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='admin' role='moderator'/>
  </x>
</presence>

在您询问之前,不,没有办法知道您何时“完成”接收这些通知,因为用户可能随时来来去去。您现在已订阅占用者的存在变化,并且必须跟踪接收方的当前状态。

Please read XEP-0045, which describes the multi-user chat (MUC) protocol. You need to join the room:

<presence
    from='[email protected]/pda'
    to='[email protected]/thirdwitch'>
  <x xmlns='http://jabber.org/protocol/muc'/>
</presence>

You'll then get a presence stanza from each occupant of the room with their current status:

<presence
    from='[email protected]/firstwitch'
    to='[email protected]/pda'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='owner' role='moderator'/>
  </x>
</presence>

<presence
    from='[email protected]/secondwitch'
    to='[email protected]/pda'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <item affiliation='admin' role='moderator'/>
  </x>
</presence>

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.

鸢与 2024-11-26 03:34:26

通读 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…

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