2011-07-09 60 views

回答

7

請閱讀XEP-0045,它描述了多用戶聊天(MUC)協議。你需要加入聊天室:

<presence 
    from='[email protected]/pda' 
    to='[email protected]/thirdwitch'> 
    <x xmlns='http://jabber.org/protocol/muc'/> 
</presence> 

然後,您會從房間它們的當前狀態的每個乘員獲得存在節:

<presence 
    from='[email protected]/firstwitch' 
    to='[email protected]/pda'> 
    <x xmlns='http://jabber.org/protocol/muc#user'> 
    <item affiliation='owner' role='moderator'/> 
    </x> 
</presence> 

<presence 
    from='[email protected]/secondwitch' 
    to='[email protected]/pda'> 
    <x xmlns='http://jabber.org/protocol/muc#user'> 
    <item affiliation='admin' role='moderator'/> 
    </x> 
</presence> 

你提問之前,沒有,沒有告訴您何時「完成」接收這些通知,因爲用戶可能隨時出入。您現在訂閱了佔用者的存在變化,並且必須跟蹤接收方當前的情況。

+0

爲了完整起見,加入房間後確實有辦法告訴所謂的[存在廣播](http://xmpp.org/extensions/xep-0045.html#enter-pres)完成:最後的存在始終是自我存在,它由一個''''''表示。 –

+0

@ max.weller我很確定有些實現會導致錯誤。 –

1

通過XMPP RFC的閱讀,我發現狀態由狀態消息傳遞,並且您要求另一個實體通過向狀態請求發送probe狀態(而不是等待它在廣播中告訴您)狀態你會得到一個指示響應(§5.5 of the RFC給出了一些例子)。這取決於你自己的意思,當然......