我如何在XMPP中获取所有在线用户的列表,假设我是管理员且XEP-133不起作用且我不在他们的名单中?
答案 0 :(得分:3)
XEP-133 中的大多数命令都可以与ejabberd一起使用。
对于一些不起作用的特定命令,包括获取在线用户,你确实是对的:我发现虽然有一些非标准的ejabberd替代方案:
如果你在主机上运行disco#items
,你可以获得一些有趣的项目:
<iq to="localhost" type="get" id="123">
<query xmlns='http://jabber.org/protocol/disco#items' />
</iq>
<iq from="localhost" type="result" to="admin@localhost/jarnas" id="123">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="conference.localhost" />
<item jid="pubsub.localhost" />
<item jid="riot.localhost" />
<item jid="vjud.localhost" />
<item node="announce" name="Announcements" jid="localhost" />
<item node="config" name="Configuration" jid="localhost" />
<item node="user" name="User Management" jid="localhost" />
<item node="online users" name="Online Users" jid="localhost" />
<item node="all users" name="All Users" jid="localhost" />
<item node="outgoing s2s" name="Outgoing s2s Connections" jid="localhost" />
<item node="running nodes" name="Running Nodes" jid="localhost" />
<item node="stopped nodes" name="Stopped Nodes" jid="localhost" />
</query>
</iq>
现在你需要“在线用户”,所以:
<iq to="localhost" type="get" id="234">
<query xmlns='http://jabber.org/protocol/disco#items' node="online users"/>
</iq>
<iq from="localhost" type="result" to="admin@localhost/jarnas" id="234" >
<query xmlns="http://jabber.org/protocol/disco#items" node="online users" >
<item name="admin@localhost" jid="admin@localhost/auto-CdB67NUOie" />
<item name="admin@localhost" jid="admin@localhost/jarnas" />
</query>
</iq>
会像魅力一样工作;)