XMPP:获取BOSH会话ID和RID

3
请告诉我如何检索SID和JID。我正在使用Strophe JS。
<body rid='489923353' xmlns='http://jabber.org/protocol/httpbind' sid='ab7f5957' to='127.0.0.1' xml:lang='en' xmpp:restart='true' xmlns:xmpp='urn:xmpp:xbosh'/>

var conn = new Strophe.Connection(bosh_service); 

然而,conn.sid 或者 conn.rid 返回的数字不同。

2个回答

2

在这个过程中,我认为我找到了答案!

else if(status === Strophe.Status.CONNECTED){

        //get roster
        var iq = $iq({type: 'get'}).c('query', {xmlns: 'jabber:iq:roster'});
        Chat.connection.sendIQ(iq, Chat.on_roster);  
        //on chat
        Chat.connection.addHandler(Chat.on_message,null, "message", "chat");

        $("#presence").html("Connection SID" + Chat.connection.sid + "Connection RID" +  Chat.connection.rid);
    }

3
使用上述代码,我得到了connection.sidconnection.rid的未定义值。 - Hunt

1
  1. 对于SID,请使用Chat.connection._proto.sid而不是Chat.connection.sid。
  2. 对于RID,请使用Chat.connection._proto.rid而不是Chat.connection.rid。
  3. 对于JID,请使用Chat.connection.jid。

SID和RID是BOSH对象的属性,而JID是Strophie对象的属性。它对我来说很好用,希望对你也有帮助。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接