How to create persistent rooms in openfire using strophe?

夙愿已清 提交于 2019-12-11 00:53:23

问题


I'm using the following iq message to create persistent rooms in openfire:

var configiq = $iq({
        to : chatObj.getActiveChatRoomName() + "@" + chatObj.groupChatService,
        type : "set"
    }).c("x", {
        xmlns : "jabber:x:data",
        type : "submit"
    }).c('field', {
        "var" : "FORM_TYPE"
    })
    .c('value').t("http://jabber.org/protocol/muc#roomconfig")
    .up().up()
    .c('field', {
        "var" : "muc#roomconfig_persistentroom"
    })
    .c('value').t("1");


chatObj.connection.sendIQ(configiq.tree(), function () {
    console.log('success');
}, function (err) {
    console.log('error', err);
});

But, I am getting the following error:

error <iq xmlns=​"jabber:​client" type=​"error" id=​"1356:​sendIQ" from=​"msrtc0711@conference.stslp239" to=​"ashishjmeshram@stslp239/​ax8nb2atg1">​<x xmlns=​"jabber:​x:​data" type=​"submit">​…​</x>​<error code=​"400" type=​"modify">​<bad-request xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-stanzas">​</bad-request>​</error>​</iq>​

回答1:


Using the Strophe.muc plugin is easier:

1) firstly join the room (this creates an instant room):

connection.muc.join(room_jid, nick);

2) then create a "configured room", eventually with a subject and a description associated:

var config = {"muc#roomconfig_publicroom": "1", "muc#roomconfig_persistentroom": "1"};
if (descr)  config["muc#roomconfig_roomdesc"] = descr;
if (subject)  config["muc#roomconfig_subject"] = subject;
connection.muc.createConfiguredRoom(room_jid, config, onCreateRoomSuccess, onCreateRoomError);

A working example is available here: http://plnkr.co/edit/Mbi15HDZ2yW5vXskS2X6?p=preview



来源:https://stackoverflow.com/questions/45588494/how-to-create-persistent-rooms-in-openfire-using-strophe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!