How do I get a list of all users online in XMPP assuming that I'm an admin and XEP-133 does not work and I'm not in their roster?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Most commands in XEP-133 do work fine with ejabberd.
You are indeed right about some particular commands not working including getting the online-users: I discovered though there are non-standard alternatives specific to ejabberd:
If you run a disco#items
on the host you get some interesting items you can query:
<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>
Now in you case you need the "Online Users" so:
<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>
will work like a charm ;)