我使用帐户管理员从我的第三方服务器登录到我的openfire XMPP服务器。
我需要在特定的多用户聊天中发现可用的用户。对于“可用”,我指的是房间里所有在线的用户。
我知道一种方法是连接到房间并监听用户的状态,但为了我的目的,我需要动态获得完整的列表。
有可能吗?
发布于 2013-04-20 05:34:51
是的,您可以使用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());
}https://stackoverflow.com/questions/15973194
复制相似问题