How to create persistent rooms in openfire using stanza?
I am using the following post iq
to create persistent numbers 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>
+2
source to share
1 answer
Using the Strophe.muc plugin is easier:
1) first join the room (this creates an instant room):
connection.muc.join(room_jid, nick);
2), then create a "configured room", eventually with an object and a description associated with it:
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
+2
source to share