Get SID & RID using strophe.js

谁都会走 提交于 2019-12-01 09:17:34

I get the RID and SID from my strophe connection by adding a function to connection.xmlOutput. This gives the ability to view the outgoing stanza's before they're sent. Here is an example:

      connection.xmlOutput = function (e) {
        if (IS_CONNECTED) {

            LAST_USED_RID = $(e).attr('rid');
            LAST_USED_SID = $(e).attr('sid');
            log(' XMLOUTPUT INFO - OUTGOING RID=' + LAST_USED_RID + ' [SID=' + LAST_USED_SID + ']');
            //log(' XMLOUTPUT INFO - OUTGOING XML = \n'+e.outerHTML);
            //set some variables to keep track of our rid and sid
        }
    };

You may also be able to access the RID and SID properties from connection's ._proto, ex:

connection._proto.rid

This may be related: https://github.com/jcbrand/converse.js/issues/180

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!