Curtis Tai
Curtis Tai

Reputation: 85

MultiUserChat get chat room user?

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.

Upvotes: 0

Views: 1341

Answers (3)

Rajan Bhavsar
Rajan Bhavsar

Reputation: 1857

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;
}

Upvotes: 0

rmldts
rmldts

Reputation: 386

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();                
     }

Upvotes: 1

Flow
Flow

Reputation: 24043

Which list?

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

Upvotes: 2

Related Questions