Strophe.js + Ejabberd-在聊天窗口加载时获取最后N条消息

时间:2020-04-30 10:44:57

标签: xmpp ejabberd strophe ejabberd-module strophe.js

I am trying to create a chat app with Gab tutorial as my base

尽管它成功创建了1-1聊天的连接,但当用户重新登录时,我无法检索到最后的N个聊天。为此,我了解以下步骤是必要的:

1. Set mod_mam: [done]
          default: always
2. Do npm install of mam plugin for strophe [done]
3. Include the following code in Gab.js:

Gab.connection.mam.query("abcd@ejabberd", {
          "with": "pqrs@ejabberd",
          onMessage: function(message) {
                    console.log("Message from ", $(message).find("forwarded message").attr("from"),
                        ": ", $(message).find("forwarded message body").text());
                    return true;
          },
          onComplete: function(response) {
                    console.log("Got all the messages");
          }
            });

Above code is directly from mam plugin tutorial

我已经在on_message: function (message)(GitHub中第108行)中包含了以上代码

我遇到以下错误:

TypeError: Cannot read property 'query' of undefined (gab.js:116)

我该如何纠正/是否有其他选择?我对Strophe和ejabberd很陌生。

0 个答案:

没有答案