在Openfire服务器中创建聊天室的问题

4
当我在多用户聊天(MUC)中尝试创建房间时,服务器会回复“此房间已锁定,直到确认配置为止”。我该如何解决这个问题?
提前感谢。
2个回答

7
你需要为房间发送配置表单。如果你正在使用Smack,代码应该类似于这样:
Form submitForm = multiUserChat.getConfigurationForm().createAnswerForm();
submitForm.setAnswer("muc#roomconfig_publicroom", false);
submitForm.setAnswer("muc#roomconfig_roomname", room);
multiUserChat.sendConfigurationForm(submitForm);

1

我在使用Openfire 3.9.3版本和Candy Chat 1.7.1时遇到了问题。

我花了一些时间阅读了多用户聊天规范(http://xmpp.org/extensions/xep-0045.html#createroom),最终找到了解决方法。首先使用Strophe,然后发现了Candy的方法。

所以回答你的问题:

在Strophe中

在发送出席(规范示例153)创建房间之后,我按照规范示例155发送了以下内容:

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

其中conn是Strophe.Connection

然后为了帮助其他可能遇到同样问题的Candy Chat用户:

在Candy Chat中

在搜索candy libs bundle中Strophe消息的片段后,我找到了这个:

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

那么,这就解决了Candy Chat中的问题。
$(Candy).on('candy:view.room.after-add', function(evt, args) {
    Candy.Core.getConnection().muc.createInstantRoom(Candy.Util.escapeJid(args.roomJid));
});

当你知道如何做时,它非常简单。顺便说一下,我认为该方法应该被称为"configureAsInstantRoom",而Candy聊天应该在init方法或类似方法中提供此选项。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接