使用 ejabberd 创建聊天室 StropheJS 时出错

Error Creating Chat Room StropheJS with ejabberd

我正在尝试使用 StropheJS 创建聊天室

我的代码:

var presence = $pres({ to:  "testRoom@conference@localhost/yashwanth, from: Strophe.getBareJidFromJid(connection.jid) });
     Groupie.connection.send( presence.tree());
    Groupie.connection.muc.createInstantRoom("testRoom@conference.localhost/yashwanth",
      function(status) {
        console.log("Room Created Successfully", status);
      },
      function(status) {
        console.log("Error Creating Room", status);
      });

创建房间时出现以下错误。

我发现roomJID的格式应该是room_name@conference@HOST@/nickname。所以按照我发送的格式。但它不会创建房间。

Error Creating Room <iq xmlns=​"jabber:​client" from=​
"conference@conference.localhost" to=​"yashwanth@inst1.eab.com/​
5441440311438943022710601" type=​"error" id=​"1:​sendIQ">​<query xmlns=​"http:​/​/​
jabber.org/​protocol/​muc#owner">​…​</query>​<error code=​"404" type=​"cancel">​
<item-not-found xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-stanzas">​</item-not-
found>​<text xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-stanzas">​Conference room 
does not exist​</text>​</error>​</iq>

我正在使用 ejabberd 作为我的 XMPP 服务器。如果房间创建,那么与房间相关的详细信息将保存在哪个数据库中?它保存在 muc_registered table 或 muc_room table?

要加入 XMPP 中的房间,您不需要先创建它。

您的代码正在做的是:

  1. 它将在线状态发送到房间,这意味着您正在加入它。如果它不存在,它将被创建。
  2. 您尝试创建房间,但应该总是失败,因为房间始终存在。
  3. 你问的是房间存放在哪里。除非它是持久的,否则它不会被存储,如果您没有配置 ejabberd 将默认房间选项设置为持久的,那么在您的示例中就不是这种情况。否则,您需要编辑 XEP-0045 Multi User Chat 中定义的房间选项以使其持久化。永久房间存储在 Mnesia table muc_room.
  4. createInstantRoom 在 StropheJS MUC 插件中使用默认选项创建房间,就像加入一样,所以我不明白为什么这里需要它。

所以,我无法判断您试图用您的代码实现什么,但只需将在线状态发送到房间就足以创建一个非持久聊天室并加入它。无需调用 createInstantRoom.