Some guidance on GroupChat and/or MultiUserChat

Hello all,

I am able to create a GroupChat using the following code:

public void createGroupChat(String user)

{

try

{

XMPPConnection connx = getConnx(user,“password”);

        GroupChat groupChat = connx.createGroupChat("testroom@conference.me.myserver.com");

groupChat.join(user);

groupChat.sendMessage(“HERE I AM”);

Iterator it = groupChat.getParticipants();

while(it.hasNext())

{

System.out.println("Occupants are "+it.next().toString());

}

}

catch(XMPPException xe){xe.printStackTrace();}

}

}

/code

Now I have a PacketListener attached to the connection and the results of having two users connect are the following:

gforty IS CONNECTED via getConnx method

testroom SAYS This room is locked from entry until configuration is confirmed. to gforty

testroom SAYS This room is now unlocked. to gforty

testroom SAYS HERE I AM to gforty

sep IS CONNECTED via getConnx method

Occupants are testroom@conference.me.myserver.com/gforty

Occupants are testroom@conference.me.myserver.com/sep

testroom SAYS HERE I AM to sep

testroom SAYS HERE I AM to sep

My question is, is this normal for the server to send these messages ie…“This room is locked…”

when each user joins the muc?

Is there a way to suppress this traffic?

also why is there a message from testroom that says HERE I AM as I would have thought that it would have read:

sep SAYS HERE I AM

since I did a groupChat.sendMessage(“HERE I AM”);?

Thanks.

If anyone has a simple implementation of MultiUserChat I would appreciate it as I searched and there was not much since it appears to be new.

TIA!

gforty wrote:

I am able to create a GroupChat using the following code:

Note that groupchat has been deprecated, you should use MUC only.

My question is, is this normal for the server to send these messages ie…“This room is locked…”

when each user joins the muc?

You have to send the configuration to the chat to unlock it.

Is there a way to suppress this traffic?

Nope.

also why is there a message from testroom that says HERE I AM as I would have thought that it would have read:

sep SAYS HERE I AM

since I did a groupChat.sendMessage(“HERE I AM”);?

You have to check the source of that packet (getFrom(): should be conferencename@server/nick).

If anyone has a simple implementation of MultiUserChat I would appreciate it as I searched and there was not much since it appears to be new.

You can check out my implementation I wrote for Adium. It’'s pretty much done and works great:

SmackXMPPMultiUserChatPlugin.m

SmackXMPPMultiUserChatPluginListener.java

might be a bit confusion though if you don’'t know Objective C.

Thanks!

Another question pertaining to MUC.

I need to create a public chat room that is accessible to ALL users.

I would prefer that there would be no login requirements, even better that the user would not even have to have a registered JID on my wildfire server. Is it possible to do this?

I was looking at the api and noticed the following:

To create an “Instant Room”, that means a room with some default configuration that is available for immediate access, the room’'s owner should send an empty form after creating the room. sendConfigurationForm(Form)

Would this do what I need?

Thanks!

gforty wrote:

Another question pertaining to MUC.

I need to create a public chat room that is accessible to ALL users.

I would prefer that there would be no login requirements, even better that the user would not even have to have a registered JID on my wildfire server. Is it possible to do this?

No, you need a regular JID. It is not required to be at the local server if using s2s, though.

To create an “Instant Room”, that means a room with some default configuration that is available for immediate access, the room’'s owner should send an empty form after creating the room. sendConfigurationForm(Form)

Would this do what I need?

This way you don’'t have to configure anything, yes.

OK Thanks, almost there…

I execute the following code and get this error:

No response from server.:

at org.jivesoftware.smackx.muc.MultiUserChat.sendConfigurationForm(MultiUserChat.j ava:556)

at chatPackage.WebConnect.createMultiUserChat(WebConnect.java:299)

/code

Now here is the code that I am running. Seems that I dont quite understand the Form object so perhaps someone can correct this.

public void createMultiUserChat(String user)

{

try

{

XMPPConnection connx = getConnx(user,“password”);

        MultiUserChat muc = new MultiUserChat(connx,"testroomMUC@conference.mydomain.com");

muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT)); //THIS IS WHERE THE ERROR POINTS

muc.join(“DUFUS”);

}

catch(XMPPException xmpe){xmpe.printStackTrace();}

}

/code

Thanks to all!

I am now able to create the MultiUserChat room with the following code:

public void createMultiUserChat(String user)

{

try

{

XMPPConnection connx = getConnx(user,“password”);

        MultiUserChat muc = new MultiUserChat(connx,"testroomMUC@conference.portal.somehere.com");

muc.create(“dufus”);

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

muc.join(“SANTA CLAUS”);

}

catch(XMPPException xmpe){xmpe.printStackTrace();}

}

/code

I get the following messages:

testroommuc SAYS This room is locked from entry until configuration is confirmed. to gforty

testroommuc SAYS This room is now unlocked. to gforty

testroommuc SAYS This room is locked from entry until configuration is confirmed. to gforty

The room shows up in the wildfire admin console.

Now when I try to join another user to the muc I get the following error:

(404)

at org.jivesoftware.smackx.muc.MultiUserChat.create(MultiUserChat.java:318)

at chatPackage.WebConnect.joinExistingMUC(WebConnect.java:312)

The code I use to join the muc is as follows:

public void joinExistingMUC(String user)

{

try

{

XMPPConnection connx = getConnx(user,“password”);

        MultiUserChat muc = new MultiUserChat(connx,"testroomMUC@conference.portal.somewhere.com");

muc.create(“SEP”);//ERROR POINTS HERE

muc.join(“SEP”,“password”);//tried with and without password

}catch(XMPPException xmpe){xmpe.printStackTrace();}

}

/code

I am sure it has something to do with the Form object??

Anyway , I did look at the extensions docs (which I had forgotten about).

Any Ideas?

Thanks again.

You should probably retrieve the form from the server (method of MultiUserChat), and get the answer form there (method of Form).

Try to check if you roomJID is in correct form:

room - the name of the room in the form “roomName@service”, where “service” is the hostname at which the multi-user chat service is running. Make sure to provide a valid JID.

I am constructing a roomJID by getting a roomName which can be any text let’'s say “555” and appending “@conference.” and then appending a XMPPConncetion.getHost()

Try not to set your domain name by yourself, rather retrieve it from the server.

Steps to create a MUC are :

MultiUserChat newGroupChat=new MultiUserChat(myConnection, roomJID);

newGroupChat.create(“MyRoom”);

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

newGroupChat.join(“dufus”);

you can also invite people to a room by

newGroupChat.invite(userJID, “Join my group chat, please”);

Message was edited by: ynikon