I'm using the account administrator to login into my openfire XMPP server, from my third party server.
I need to discover the available users into specific multi-user-chat. For "available" I mean all the users ONLINE in the room.
I know that the one way is to connect to room and listen for users presence, but for my purpose I need to get the complete list on the fly.
Is it possible?
Yes you can use the ServiceDiscovery for that. Here is a example:
// 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());
}