2013-03-19 30 views
-1

我使用strophe librabry成功連接到openfire服務器。使用strophe獲取在線用戶列表xmpp

我想要一個可以從會議室返回所有用戶的javascript函數。

另一個問題是:我如何設置/獲取當前用戶的狀態?

我當前的代碼:

$(document).ready(function() { 
    connection = new Strophe.Connection(BOSH_SERVICE); 
    connection.connect("null", 
      "null", 
      onConnect); 
}); 

function onConnect(status) 
{ 
    if (status == Strophe.Status.CONNECTED) { 
     $('#notifications').html('<p class="welcome">Hello! Any new posts will appear below.</p>'); 
     connection.addHandler(notifyUser, null, 'message', null, null, null); 
     console.log('send '); 
     var pres = $pres({to: '[email protected]/catalin'}); 
     connection.send(pres); 


    } 
} 

回答

1

您發送初始的存在後,你會得到一個名冊。

http://xmpp.org/rfcs/rfc6121.html#roster-login - 如何檢索登錄後的花名冊。

要獲得某人的存在,您需要發送一個存在智商。然後獲取狀態元素。

,如果你想看看,我已經使用strophe.js建立我xmppp客戶端,請訪問:http://hularing.me/

+0

感謝,正是想我需要的。順便說一句,我試圖登錄hularing,但我說連接到服務器失敗。我需要特殊的身份證/密碼嗎? – Catalin 2013-03-20 12:55:57