0

I am working on ASmack. Is it workable to get chat room user list using asmack? http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/muc.html This list have not shown. Please give me some idea.

Curtis Tai
  • 85
  • 2
  • 13

3 Answers3

2

Which list?

You can only call getOccupants() if you are an occupant of the MUC or, in other words, if have joined the MUC.

Flow
  • 23,572
  • 15
  • 99
  • 156
  • I am calling getOccupants() but it's not returning occupants list all time. according to my problem i asked one Question in SO look at this http://stackoverflow.com/questions/16335872/how-to-get-list-of-occupants-from-room-in-multiuserchat , and tell me how to solve this. – RajaReddy PolamReddy May 02 '13 at 10:46
1

getOccupants() doesnt work for me. So you can try the code below:

 try {         
       ServiceDiscoveryManager discoManager =  ServiceDiscoveryManager.getInstanceFor(xmppConn);
       DiscoverItems discoItems = discoManager.discoverItems(roomJID);
       Iterator<DiscoverItems.Item> occupants = discoItems.getItems();  

     } catch (XMPPException e) {
       e.printStackTrace();                
     }
rmldts
  • 366
  • 3
  • 10
  • I am using 4.1.0 rc1 and i am not able to get occupants by getOccupants(). ServiceDiscoveryManager works for me. – Hitendra Apr 02 '15 at 08:21
0

i was able to get the List Of user's available in the Chat Room Of XMPP by the Simple Following Method passing the Parameter as MultiUserChat Object.

public static List<String> findMulitUser(MultiUserChat muc) {
    List<String> listUser = new ArrayList<String>();
    Iterator<String> it = muc.getOccupants();
    // Traverse the chat room name
    while (it.hasNext()) {
        // Chat room members name
        String name = StringUtils.parseResource(it.next());
        System.out.println("Name Of Occupants------>" + name);
        listUser.add(name);
    }
    return listUser;
}
Rajan Bhavsar
  • 1,977
  • 11
  • 25