我有以下问题:
如何在成功连接到openfire服务器后获取这三个(JID,SID和RID)参数?与Babbler相比,获取它们相对容易,但是使用Smack很难找到它。
最诚挚的问候。
答案 0 :(得分:1)
您可以通过此链接找到所需内容: Java - trying to prebind converse.js using bosh but not able to get the sid and rid...using the smack bosh
其他方式,如果你可以使用javascript来获取jid,sid和rid,你可以参考下面:
您可以先使用strophe.js
创建一个bosh绑定,然后从连接中获取它们。
//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 = 'admin@127.0.0.1';
var password = 'admin';
connection = new Strophe.Connection(BOSH_SERVICE);
connection.connect(jid,
password,
onConnect);
然后从onConnect()
函数中获取详细信息:
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 + "]");
}
}
祝你好运!