开发者

Problem in creating a chat room in openfire server

When I try to create a room in Multi User Chat (MUC) the server responds 'This room is locked from entry until configuration is confirme开发者_开发技巧d'. How can I overcome this?

Thanks in advance


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);


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜