Project

General

Profile

How to get all the room members in the MUC module?

Ralph Hammerfell
Added about 3 years ago

We're adding a little functionality to send push notifications for MUC members that are offline/out of the room. We checked the MUC module code, and it's doing the following:

room.getOccupantsNicknames()

But I think that will only get us a list of the members currently in the room, and not all the members in the list, correct? How can we get a list of all the members belonging to that room, whether they are online or not?


Replies (1)

Avatar?id=6098&size=32x32

Added by Bartosz Małkowski TigaseTeam about 3 years ago

Hi!

I'm not sure what you exactly have in mind. MUC doesn't keeps list of all occupants joined to room in the past if now they are disconnected now. If user disconnects, then Server sends presence offline to MUC what is equals to leaving room, and MUC forgets about him.

But if you have members-only room, each occupant must be stored in MUC database with assigned affiliation. You can get it with tigase.muc.Room#getAffiliations (I know, very intuitive method name) and you can iterate over this list and check affiliation of each users with affiliation (@tigase.muc.Room#getAffiliation(tigase.xmpp.BareJID)@).

Please check XEP-0045 to see how affiliations works.

    (1-1/1)