Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem in creating a chat room in openfire server

Tags:

xmpp

openfire

When I try to create a room in Multi User Chat (MUC) the server responds 'This room is locked from entry until configuration is confirmed'. How can I overcome this?

Thanks in advance

like image 883
HoneySam Avatar asked Feb 23 '23 03:02

HoneySam


2 Answers

You need to send a configuration form for the room. If you are using smack the code would look something like this:

Form submitForm = multiUserChat.getConfigurationForm().createAnswerForm();
submitForm.setAnswer("muc#roomconfig_publicroom", false);
submitForm.setAnswer("muc#roomconfig_roomname", room);
multiUserChat.sendConfigurationForm(submitForm);
like image 73
Flow Avatar answered Mar 18 '23 06:03

Flow


I was having this problem using Candy Chat 1.7.1 with Openfire 3.9.3.

This took me a while to work out, but after reading through the Multi-User Chat spec: http://xmpp.org/extensions/xep-0045.html#createroom

I eventually solved it; first with Strophe, then from that found the Candy way.

So to answer your question:

In Strophe

After creating the room by sending the presence (Example 153 in spec)

I sent the below (as per Example 155 in spec)

conn.sendIQ($iq({
    type: "set",
    to: escapedRoomId,
    from: me.getEscapedJid(),
    id: "create:" + conn.getUniqueId()
}).c("query", {
    xmlns: "http://jabber.org/protocol/muc#owner"
}).c("x", {
    xmlns: "jabber:x:data",
    type: "submit"
}));

where conn is the Strophe.Connection

Then to help others who may have the same problem in Candy Chat:

In Candy Chat

After searching for bits of the Strophe message above in the candy libs bundle I found this:

createInstantRoom: function(room, success_cb, error_cb) {
    var roomiq;
    roomiq = $iq({
        to: room,
        type: "set"
    }).c("query", {
        xmlns: Strophe.NS.MUC_OWNER
    }).c("x", {
        xmlns: "jabber:x:data",
        type: "submit"
    });
    return this._connection.sendIQ(roomiq.tree(), success_cb, error_cb);
},

So then this solves it in Candy Chat.

$(Candy).on('candy:view.room.after-add', function(evt, args) {
    Candy.Core.getConnection().muc.createInstantRoom(Candy.Util.escapeJid(args.roomJid));
});

Irritatingly simple when you know how. Incidentally I think the method should be called configureAsInstantRoom and Candy chat should have an option for this on the init method or similar.

like image 35
Chris Jordan Avatar answered Mar 18 '23 05:03

Chris Jordan