Get SID & RID using strophe.js

前端 未结 1 457
陌清茗
陌清茗 2021-01-14 17:42

How can I get the SID & RID when connecting to a XMPP server using strophejs ? I am using Ejabbered as the XMPP server.

Here is my code

        $         


        
相关标签:
1条回答
  • 2021-01-14 17:59

    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

    0 讨论(0)
提交回复
热议问题