1
我使用帳戶管理員從我的第三方服務器登錄到我的openfire XMPP服務器。Smack在線用戶的多用戶聊天列表
我需要將可用用戶發現爲特定的多用戶聊天。對於「可用」,我的意思是在房間內的所有用戶在線。
我知道,一種方式是連接到房間,並聽取用戶的存在,但爲了我的目的,我需要在飛行中獲得完整列表。
可能嗎?
我使用帳戶管理員從我的第三方服務器登錄到我的openfire XMPP服務器。Smack在線用戶的多用戶聊天列表
我需要將可用用戶發現爲特定的多用戶聊天。對於「可用」,我的意思是在房間內的所有用戶在線。
我知道,一種方式是連接到房間,並聽取用戶的存在,但爲了我的目的,我需要在飛行中獲得完整列表。
可能嗎?
是的,你可以使用ServiceDiscovery。這裏有一個例子:
// Obtain the ServiceDiscoveryManager associated with my Connection
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
// Get the items of a given XMPP entity
// This example gets the items associated with online catalog service
DiscoverItems discoItems = discoManager.discoverItems("plays.shakespeare.lit");
// Get the discovered items of the queried XMPP entity
Iterator it = discoItems.getItems();
// Display the items of the remote XMPP entity
while (it.hasNext()) {
DiscoverItems.Item item = (DiscoverItems.Item) it.next();
System.out.println(item.getEntityID());
System.out.println(item.getNode());
System.out.println(item.getName());
}
請記住,這隻會走到半路有:將列出聊天室,它會列出用戶在每個聊天,但不會列出*真正*用戶的JID。 –