0
votes

I am creating group chat application where multiple user can communicate with each other. I can't understand how can I fetch all the user created chat room from the openfire server using smack api.

1

1 Answers

0
votes

First step:

check for services available on server.

Each service can host 0 or more groupchat. By default, Openfire just register a single service, the default name is conference.

List<String> services = MultiUserChatManager.getInstanceFor( connection ).getServiceNames();

Second step:

check all the hosted groupchat and store the result as you need. For example:

Map<String, List<HostedRoom>> chatroomInServices = new HashMap<String,List<HostedRoom>)(services.size());

for (String service : services)
{
 chatroomInServices.put(service, MultiUserChatManager.getInstanceFor( connection ).getHostedRooms( service  ) );
}

    for (List<HostedRoom> hosted: chatroomInServices.values())
   {
      for (HostedRoom room : hosted)
     {
       room.getJid();  // [email protected]
     }
   }

Probably you'll need to store also each roomJid