Question

Please tell me how to retrieve the SID and JID. I am using 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); 

However, conn.sid or conn.rid is not returning the same numbers.

Was it helpful?

Solution

After this and that, I think I found the answer!

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);
    }

OTHER TIPS

  1. For SID use Chat.connection._proto.sid instaed of Chat.connection.sid.
  2. For RID use Chat.connection._proto.rid instaed of Chat.connection.rid
  3. For JID use Chat.connection.jid .

Here SID and RID are properties of BOSH object where as JID is the property of Strophie object. It is working for me fine. I hope it will work for you also.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top