Questions about multiuserchat

Hi everyone,

I have some questions on using multiuserchat which confuse me a whloe night.

I know the basic mehod to create a chat room.

MultiUserChat muc=new MultiUserChat( connectin , groupaddress)
muc.join(nickname)
muc.addMessageListener(......)

The documents says it will create a multi user chat. But if the groupaddress is an existed group, will I join the group or create a new one?

http://www.igniterealtime.org/builds/smack/docs/3.4.0/javadoc/org/jivesoftware/s mackx/muc/MultiUserChat.html#MultiUserChat(org.jivesoftware.smack.Connection, java.lang.String)

if I run the code above twice, what will happen?

MultiUserChat muc=new MultiUserChat( connectin , groupaddress)
muc.join(nickname)
muc.addMessageListener(......)
muc=new MultiUserChat( connectin , groupaddress)
muc.join(nickname)
muc.addMessageListener(......)

I think the messasgelistener is a thread. Are the both threads running now or only the latest one?

How can I join more than one rooms and addmessagelistener?

Thank you all.

Strong Su

The documents says it will create a multi user chat. But if the groupaddress is an existed group, will I join the group or create a new one?
‘join()’ joins a groupchat. Sometimes, depending on the server, this also means creating it if it doesn’t already exist.

Smack 4 has createOrJoin() which will create a groupchat if it doesn’t exists or otherwise join.

I think the messasgelistener is a thread.

No it’s not. But there is a Thread that invokes the matching message listeners.

Are the both threads running now or only the latest one?

It depends on the MUC if both message listeners will be invoked or not.

How can I join more than one rooms and addmessagelistener?
Create a new muc instance

MUC muc2 = new MultiUserChat(…)

Thank you very much. My project is running perfectly now.