powered by Jive Software

getParticipants

Hi,

I’'m trying to get the participants of the Room i joined.

But i always get participantscount=0 and an empty iterator as result of muc.getParticipants()

MultiUserChat newGroupchat=new MultiUserChat(conn,roomname);

try {newGroupchat.join(nickname);

Iterator roster=newGroupchat.getParticipants();

System.out.println(newGroupchat.getParticipantCount());

}

catch (XMPPException e1) {

e1.printStackTrace();

}

could anybody tell me what i am doing wrong?

thanks

Jan,

Since you are getting the participants right after you’‘ve joined the room it’‘s possible that Smack hasn’'t received that information from the server yet.

You can open a debugger to see if and when you are receiving the room participants from the server.

Regards,

– Gato

i have created a ‘‘sleep’’ method whitch creates a waiting period between joining the room and getting the participants…still the same problem…

MultiUserChat newGroupchat=new MultiUserChat(conn,roomname);

try {newGroupchat.join(nickname);

Iterator roster=newGroupchat.getParticipants();

Sleep.sleep(5000); //wait 5000msec

System.out.println(newGroupchat.getParticipantCount());

}

catch (XMPPException e1) {

e1.printStackTrace();

}

Jan,

Try opening the window debugger to find out if you are actually receiving the participants from the server. You should receive at least one presence (from you) if no one is in the room at that moment.

Once you have received the participants’’ presences try again with the #getParticipants() and #getParticipantCount() messages.

– Gato