本文介绍了如何使用Strophe在明火中创建持久性房间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下iq
消息在openfire中创建持久房间:
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="[email protected]" 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>
推荐答案
使用 Strophe.muc 插件更容易:
1)首先加入房间(这将创建一个即时房间):
1) firstly join the room (this creates an instant room):
connection.muc.join(room_jid, nick);
2)然后创建一个配置房间",最终将其与主题和描述相关联:
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);
此处提供了一个工作示例: http://plnkr.co/edit/Mbi15HDZ2yW5vXskS2X6? p =预览
A working example is available here: http://plnkr.co/edit/Mbi15HDZ2yW5vXskS2X6?p=preview
这篇关于如何使用Strophe在明火中创建持久性房间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!