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