2017-10-18 40 views
0

抱歉打擾任何人,但我真的需要這種幫助,我想從數據庫中檢索聊天(我之前已經問這個問題),但我嘗試使用Google和讀取所有文檔,我認爲我已經找到了解決辦法,我讀了converse.js文檔中關於開發者API,在歸檔組部分,我得到這個:無法讀取屬性「getUniqueId」的未定義

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

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

    this._converse.api.archive.query({'with': '[email protected]'}); 

    } 
}); 


     converse.initialize({ 

       jid: '[email protected]', 
       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,因爲它具有完整的功能和文檔。

回答

0

一個Converse.js插件的initialize方法被當Converse.js本身被初始化調用。

這發生在用戶登錄之前(無論是自動還是手動)。

因此,您在用戶登錄並建立了XMPP連接和會話之前調用了this._converse.api.archive.query({'with': '[email protected]'});

相反,您應該先聽聽connection事件,然後再進行查詢。

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

     _converse.on('connected', function() { 
      _converse.api.archive.query({'with': '[email protected]'});  
     }); 
    } 
}); 
+0

謝謝jc,我得到了mam的問題,只是發現我的xmpp服務器不支持urn:xmpp:mam:2,所以它'無法從數據庫中取回數據 – Prem

相關問題