2017-02-20 30 views
0
的實際版本RID

我有以下問題:如何獲得JID,SID和啪

我怎麼能這三個(JID,SID和RID)參數後成功連接到一個Openfire的服務器獲取?與Bab啞者相處很容易就可以得到他們,但與Smack有點兒困難,當不是不可能的時候,找到它。

最好的問候。

回答

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和趕走,你可以在下面參考: 您可以使用strophe.js創建波什首先綁定,然後從連接中獲取它們。

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

,然後從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 + "]"); 
    } 
} 

好運!

+0

哦......我沒有注意到你正在使用smack庫... –