无法读取未定义的属性“getUniqueId”

预科

抱歉打扰任何人,但我真的需要帮助,我想从数据库中检索聊天(我之前已经问过这个问题),但我尝试谷歌搜索并阅读所有文档,我认为我已经找到了解决方案,我存档组部分阅读了有关开发人员 api的 converse.js 文档,我得到了这个:

   require(['converse'], function (converse) {

converse.plugins.add('myplugin', {
    initialize: function () {

     this._converse.api.archive.query({'with': 'admin2@localhost'});

    }
});


        converse.initialize({

                jid: 'admin3@localhost',
                authentication: 'prebind',
                prebind_url: 'bind/bind.php',
                allow_logout: false,
                debug : true,
                whitelisted_plugins: ['converse-inverse','converese-mam','converse-singleton','converse-muc-embedded','myplugin'],
                archived_messages_page_size : 20,
                message_archiving : "always",
                auto_list_rooms: false, 
                show_chatstate_notifications:true,
                message_carbons : true,
                sounds_path : "sounds/",
                auto_reconnect : true,
                use_vcard : true,
                auto_subscribe: false,
                keepalive : true,
                show_send_button:true,
                archived_messages_page_size : 20,
                bosh_service_url: 'http://localhost:5280/http-bind', 
                hide_muc_server: false,
                play_sounds : true,
                show_controlbox_by_default: false,
                xhr_user_search: false

        });


    });

我试过了,但我收到了这个错误:

Cannot read property 'getUniqueId' of undefined
    at Object._converse.queryForArchivedMessages (converse-mam.js:266)
    at Object.initialize (dev.html:30)
    at PluginSocket.initializePlugin (pluggable.js:196)
    at arrayEach (lodash.js:537)
    at Object.forEach (lodash.js:9359)
    at PluginSocket.initializePlugins (pluggable.js:227)
    at Object.initPlugins (converse-core.js:1854)
    at Object._converse.initialize (converse-core.js:1875)
    at Object.initialize (converse-core.js:2037)
    at dev.html:36

如果这个问题有点简单或愚蠢,我很抱歉,但我在使用 converse.js 方面真的很新,而且我真的很喜欢在未来使用和了解有关 converse.js 的更多信息,因为它具有完整的功能和文档。

JC品牌

initializeConverse.js 插件方法在 Converse.js 本身被初始化时被调用。

这发生在用户登录之前(无论是自动发生还是手动发生)。

因此,您在this._converse.api.archive.query({'with': 'admin2@localhost'});用户登录并建立 XMPP 连接和会话之前调用

相反,您应该首先监听connection事件,然后进行查询。

converse.plugins.add('myplugin', {
    initialize: function () {
        var _converse = this._converse;

        _converse.on('connected', function () {
            _converse.api.archive.query({'with': 'admin2@localhost'});    
        });
    }
});

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章