powered by Jive Software

getParticipants vs getOccupants

Hi, I need to put all participants in MUC in JTextPane on the right (pretty straight-forward stuff… just need nicknames to show up on the right…)

I tried getParticipants() but can’‘t get that to work b/c can’'t do

while (chatters.hasNext()) {

with a Collection…

also couldn’‘t do getOccupants() b/c getOccupants() returns an iterator (not Occupants), so can’'t do occupant.getNick();

(would be nice if there were a method that just returned Collection of nicknames (in String form…) but I guess that would be too simple… I’'m on 1.4, not 1.5…:wink:

I mean how do I do getNick() here…

public void getChatters() {

Iterator chatters;

chatters = EventChat.getOccupants();


while (chatters.hasNext()) {

chatters.getNick(); // ******** error…

// System.out.println(chatters);

String theChatter = chatters.toString();

// String theChatter = StringUtils.parseResource(chatters.next());

String theChatters = theChatter + “\n”;





disreagard – sorry…

(but back to same old problem: most challenging thing here: how do you find out if MUC exists before creating it… just can’'t get this one together…

if MUC exists // (find out how?)





thank you…

why would you want to know that (if you want… you need to use Service discovery: http://www.jivesoftware.org/builds/smack/docs/latest/documentation/extensions/di sco.html#discoitems ) ?

either the user says he wants to create a room or join it …

or you should simply use join …

see http://www.jabber.org/jeps/jep-0045.html#enter-nonexistent

afaik … the only difference between join and create is that join will try downloading a message history and create will try to confirm the creation of the room…


Herbert Poul


you need to:

String theChatter = chatters.next().toString();

check out the Iterator java docs for more info.

thank you very much for yr response… looking into using disco as you said… user does NOTHING in our system, everything done by us… in our system users click on ‘‘chat’’ button next thing they know they’'re inside MUC…

we reg/log them in (users already reg’‘d w/us, we pass all info in query string) room created (in sw, not by users, room name info also passed in query string) as soon as they launch chat – IF they are the first to launch chat (and thus MUC doesn’'t exist yet) if somone else already has launched chat then MUC already exists and I need to use join() instead of create()

right now am doing like this:

try {


System.out.println(“room joined”);

} catch (XMPPException e) {

XMPPError error = e.getXMPPError();

if (error.getCode() == 404) {

try {


System.out.println(“room created”);

aChat.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));

} catch (XMPPException ee) {

System.out.println("Exception Caught: " + ee.getMessage() + " " + ee);




but: if I run it again after room has been created/joined (send query string again w/diff info for MUC name, for ex) get this very weird error have never seen before:

java.io.EOFException: no more data available - expected end tag … @1:1275

dont’'t get at all what this is… would appreciate some leads… thank you very much…

can you post all your raw sent and received packets?