1

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?

CeccoCQ
  • 3,746
  • 12
  • 50
  • 81

1 Answers1

1

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());
      }
Roman S.
  • 1,206
  • 15
  • 24
  • Please, keep in mind that this will only go halfway there: it will list the chat rooms, it will list the users in each chat, but it won't list the *real* JIDs of the users. – Haroldo_OK Sep 30 '16 at 17:46