0

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.

tarun bhutani
  • 31
  • 1
  • 3

1 Answers1

0

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();  // user@conference.server
     }
   }

Probably you'll need to store also each roomJid

MrPk
  • 2,862
  • 2
  • 20
  • 26