How to get occupants on MUC after joigning

Hello,

I’m working on this for a while but I don’t find how to make this working.

I’m able to get new occupants when they join or leave, but I’m unable to get current occupants when I join a conference.

occupants.hasNext() returns false and #getOccupantsCount returns zero.

Any help will be apreciated! Thanks!

This is the code I have :

// Constructeur join d'une conférence existante avec mot de passe
    public ConferenceJabber(String strNomConference, String strMotPasse)
    {                // initialisation des paramètre de la salle de conférence
        this.blnInitiateur = false;
        this.strNomConference = strNomConference.split("@")[0];
        this.strNomConferenceComplet = strNomConference;
        this.strMotPasse = strMotPasse;
        this.laConference = new MultiUserChat(Main.getJabberInstance().getConnexionInstance(), strNomConference);         // ajout des listeners
        addListeners(this);         // join de la conférence
        try
        {
            laConference.join(Main.getJabberInstance().getNom(), strMotPasse);
        }
        catch (XMPPException ex)
        {
            java.util.logging.Logger.getLogger(ConferenceJabber.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }         recupererLesOccupants();
    }     private void recupererLesOccupants()
    {
        Iterator<String> occupants = laConference.getOccupants();
        int bidon = laConference.getOccupantsCount();
        while (occupants.hasNext())
        {
            String jidOccupant = occupants.next();
            ContactConference contactConference = new ContactConference(jidOccupant);
            this.lesParticipants.put(contactConference.getJid(), contactConference);
            fireParticipantJoin(contactConference);
        }
    }      private void addListeners(final ConferenceJabber confJabber)
    {
        laConference.addMessageListener(messageListener = new PacketListener()
        {
            public void processPacket(Packet packet)
            {
                // traite un message texte
                if (packet instanceof Message)
                {
                    Message message = (Message) packet;                     if (message != null && message.getBody() != null)
                    {
                        Main.getFenetreDialogueInstance().traiteMessageEntrantConference(message, confJabber);
                    }
                }
            }
        });         laConference.addParticipantListener(participantListener = new PacketListener()
        {
            public void processPacket(Packet packet)
            {
                // traite un paquet de présence (join ou quitte la conférence)
                if (packet instanceof Presence)
                {
                    Presence presence = (Presence) packet;                     if (presence!=null)
                    {
                        ContactConference contactConf = new ContactConference(presence);                         if (presence.getType()==Type.available)
                        {
                            lesParticipants.put(contactConf.getJid(), contactConf);
                            fireParticipantJoin(contactConf);
                        }
                        else if (presence.getType()==Type.unavailable)
                        {
                            lesParticipants.remove(contactConf.getJid());
                            fireParticipantQuitte(contactConf);
                        }
                    }
                }
            }
        });     }

Nobody know how to get occupants list on a MUC ?

If I have no replies is it because this is not doable !?

My attemps to have getOccupants() return anything have failed so far.

I resorted to send the participants IDs through a custom property in the invitation.

Spark itself seems to be using it only once in a not so critical section.

Hello,

Your idea seem fine because my IM will only use my client, so I can bypass the standard way to get occupants’ list.

How do you set the custom properties when sending the invitation ?

Thanks!

The easiest is to use the setProperty method in org.jivesoftware.smack.packet.Packet


Mmm how do you use that method when you send your invitations ?

Thanks for the help!