Smack api get all public rooms on openfire server

I am using XMPP smack api to connect to an Openfire server. I am trying to request a server to return all available public rooms without knowing these room names in advance. The purpose of this is that my client can display a list of all available public rooms and join them accordingly. The Smack Extensions documentation contains some examples of returning number information from the server, however none of them work for me.

In one example, you need to know the name of the room in advance, which is not good if you want to display available rooms that the client otherwise does not know about. The code for this example is as follows.

 // Discover information about the room roomName@conference.myserver
  RoomInfo info = MultiUserChat.getRoomInfo(conn, "roomName@conference.myserver");
  System.out.println("Number of occupants:" + info.getOccupantsCount());
  System.out.println("Room Subject:" + info.getSubject());

Another example allows you to request rooms in which all your contacts are located. This is apparently a very indirect way to get room names and may leave some of the rooms. Since XMPP is a server-based protocol and not a p2p-based protocol, this does not seem to be the most logical way to achieve it (although please correct me if I am wrong). This sample code is as follows

 Iterator joinedRooms = MultiUserChat.getJoinedRooms(conn, "user3@host.org/Smack");

If someone can either send me a link or give an example of how to do this, we will be very grateful.

+4
source share
1 answer

It appears that MultiUserChat.getHostedRooms () is what you are looking for.

+2
source

All Articles