Juan BC
Juan BC

Reputation: 196

How to get JID, SID and RID from actual version of Smack

I have the following problem:

How can i get these three (JID, SID and RID) parameters after a successful connection to an openfire server?? with Babbler it is relative easy to get them, but with Smack is kinda of difficult, when not impossible, to find it.

Best Regards.

Upvotes: 0

Views: 664

Answers (1)

Emeric Liu
Emeric Liu

Reputation: 11

You may find what you need by this link: Java - trying to prebind converse.js using bosh but not able to get the sid and rid...using the smack bosh

Other way, if you can use javascript to get jid, sid and rid, you can refer below: You can use strophe.js to create a bosh bind first, then get them from the connection.

//I user local openfire here
var BOSH_SERVICE = 'http://127.0.0.1:7070/http-bind/'; 
var connection = null;  
//you can get your usr and pwd in other way
var jid = '[email protected]';
var password = 'admin';

connection = new Strophe.Connection(BOSH_SERVICE);
        connection.connect(jid,  
                password,  
                onConnect);

and then get the detail from onConnect() function like this:

function onConnect(status)  
{ 
    if (status == Strophe.Status.CONNECTED) { 
        //then you can get what you want
        console.log("---SID[" + connection._proto.sid + "] RID[" +  connection._proto.rid + "] JID[" + jid + "]");
    }
}

good luck!

Upvotes: 1

Related Questions