日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

xmpp muc 群聊协议 3

發(fā)布時間:2023/12/9 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 xmpp muc 群聊协议 3 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

6.?Entity Use Cases

A MUC implementation MUST support?Service Discovery?[7].

服務(wù)端必須實現(xiàn) service discover

6.1?Discovering Component Support for MUC

發(fā)現(xiàn)服務(wù)器是否支持muc

A Jabber entity may wish to discover if a service implements the Multi-User Chat protocol; in order to do so, it sends a service discovery information ("disco#info") query to the component's JID:

一個jabber實體會去詢問服務(wù)器,是否服務(wù)器端支持muc的協(xié)議。

例子1 : 用戶向服務(wù)器詢問是否支持muc的協(xié)議

iq get 協(xié)議 xmlns = "http://jabber.org/protocol/disco#info"

<iq from='hag66@shakespeare.lit/pda' fuul jid
? ? id='disco1'
? ? to='chat.shakespeare.lit' 服務(wù)器
? ? type='get'>
? <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
? ?

The service MUST return its identity and the features it supports:

服務(wù)器必須返回是否支持muc群聊

Example 2. Service Returns Disco Info Results

<iq from='chat.shakespeare.lit' 服務(wù)器
? ? id='disco1'
? ? to='hag66@shakespeare.lit/pda' jid
? ? type='result'>
? <query xmlns='http://jabber.org/protocol/disco#info'>
? ? <identity
? ? ? ? category='conference'
? ? ? ? name='Macbeth Chat Service'
? ? ? ? type='text'/>
? ? <feature var='http://jabber.org/protocol/muc'/>
? </query>
</iq>
? ?

Note: Because MUC is a superset of the old "groupchat 1.0" protocol, a MUC service SHOULD NOT return a <feature var='gc-1.0'/> entry in a disco#info result.

6.2?Discovering Rooms

發(fā)現(xiàn)房間

The service discovery items ("disco#items") protocol enables a user to query a service for a list of associated items, which in the case of a chat service would consist of the specific chat rooms hosted by the service.

?

Example 3. User Queries Chat Service for Rooms

<iq from='hag66@shakespeare.lit/pda' jid
? ? id='disco2'
? ? to='chat.shakespeare.lit' server
? ? type='get'>
? <query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
? ?

The service SHOULD return a full list of the rooms it hosts.

Example 4. Service Returns Disco Item Results

服務(wù)器返回disco item 的結(jié)果

<iq from='chat.shakespeare.lit' server
? ? id='disco2'
? ? to='hag66@shakespeare.lit/pda' jid
? ? type='result'>
? <query xmlns='http://jabber.org/protocol/disco#items'>
? ? <item jid='heath@chat.shakespeare.lit'
? ? ? ? ? name='A Lonely Heath'/>
? ? <item jid='darkcave@chat.shakespeare.lit'
? ? ? ? ? name='A Dark Cave'/>
? ? <item jid='forres@chat.shakespeare.lit'
? ? ? ? ? name='The Palace'/>
? ? <item jid='inverness@chat.shakespeare.lit'
? ? ? ? ? name='Macbeth&apos;s Castle'/>
? </query>
</iq>
? ?

If the full list of rooms is large (see XEP-0030 for details), the service MAY return only a partial list of rooms. If it does so, it SHOULD include a <set/> element (as defined inResult Set Management?[8]) to indicate that the list not the full result set.

如果全部房間列表太長,服務(wù)器可以返回一部分房間列表。如果這樣做了,服務(wù)器返回的內(nèi)容應(yīng)該包含一個set節(jié)點,代表返回的列表不是全部列表

Example 5. Service Returns Limited List of Disco Item Results

<iq from='rooms.shakespeare.lit' server
? ? id='disco-rsm-1'
? ? to='hag66@shakespeare.lit/pda'jid
? ? type='result'>
? <query xmlns='http://jabber.org/protocol/disco#items'>
? ? <item jid='alls-well-that-ends-well@rooms.shakespeare.lit'/> itmes
? ? <item jid='as-you-like-it@rooms.shakespeare.lit'/>
? ? <item jid='cleopatra@rooms.shakespeare.lit'/>
? ? <item jid='comedy-of-errors@rooms.shakespeare.lit'/>
? ? <item jid='coriolanus@rooms.shakespeare.lit'/>
? ? <item jid='cymbeline@rooms.shakespeare.lit'/>
? ? <item jid='hamlet@rooms.shakespeare.lit'/>
? ? <item jid='henry-the-fourth-one@rooms.shakespeare.lit'/>
? ? <item jid='henry-the-fourth-two@rooms.shakespeare.lit'/>
? ? <item jid='henry-the-fifth@rooms.shakespeare.lit'/>
? ? <set xmlns='http://jabber.org/protocol/rsm'>
? ? ? <first index='0'>alls-well-that-ends-well@rooms.shakespeare.lit</first>
? ? ? <last>henry-the-fifth@rooms.shakespeare.lit</last>
? ? ? <count>37</count>
? ? </set>
? </query>
</iq>
? ?

6.3?Querying for Room Information

查詢房間消息

Using the disco#info protocol, a user may also query a specific chat room for more detailed information about the room. A user SHOULD do so before entering a room in order to determine the privacy and security profile of the room configuration (see the?Security Considerations?for details).

?

用 disco#info 協(xié)議,用戶也可以查詢一個指定的房間的信息,一個用戶應(yīng)該在進入一個房間之前來確定這個房間的隱私和安全配置?

?

Example 6. User Queries for Information about a Specific Chat Room

<iq from='hag66@shakespeare.lit/pda' jid
? ? id='disco3'
? ? to='darkcave@chat.shakespeare.lit' roomid
? ? type='get'>
? <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
? ?

The room MUST return its identity and SHOULD return the features it supports:

房間必須返回他的屬性

Example 7. Room Returns Disco Info Results

<iq from='darkcave@chat.shakespeare.lit' roomid
? ? id='disco3'
? ? to='hag66@shakespeare.lit/pda' jid
? ? type='result'>
? <query xmlns='http://jabber.org/protocol/disco#info'>
? ? <identity
? ? ? ? category='conference'
? ? ? ? name='A Dark Cave'
? ? ? ? type='text'/>
? ? <feature var='http://jabber.org/protocol/muc'/>
? ? <feature var='muc_passwordprotected'/>
? ? <feature var='muc_hidden'/>
? ? <feature var='muc_temporary'/>
? ? <feature var='muc_open'/>
? ? <feature var='muc_unmoderated'/>
? ? <feature var='muc_nonanonymous'/>
? </query>
</iq>
? ?

Note: Because MUC is a superset of the old "groupchat 1.0" protocol, a MUC room SHOULD NOT return a <feature var='gc-1.0'/> entry in a disco#info result. The room SHOULD return the materially-relevant features it supports, such as password protection and room moderation (these are listed fully in the feature registry maintained by the XMPP Registrar; see also the?XMPP Registrar?section of this document).

應(yīng)該返回一些有用的支持特征。 比如是否是密碼房間,是否是moderation房間等。

?

A chatroom MAY return more detailed information in its disco#info response using?Service Discovery Extensions?[9], identified by inclusion of a hidden FORM_TYPE field whose value is "http://jabber.org/protocol/muc#roominfo". Such information might include a more verbose description of the room, the current room subject, and the current number of occupants in the room:

一個聊天室或許會返回一些擴展信息,用muc#roominfo這個擴展的xmlns,包含更多的房間的信息,例如房間的用戶的信息。

?

Example 8. Room Returns Extended Disco Info Results

<iq from='darkcave@chat.shakespeare.lit'
? ? id='disco3a'
? ? to='hag66@shakespeare.lit/pda'
? ? type='result'>
? <query xmlns='http://jabber.org/protocol/disco#info'>
? ? <identity
? ? ? ? category='conference'
? ? ? ? name='A Dark Cave'
? ? ? ? type='text'/>
? ? <feature var='http://jabber.org/protocol/muc'/>
? ? <feature var='muc_passwordprotected'/>
? ? <feature var='muc_hidden'/>
? ? <feature var='muc_temporary'/>
? ? <feature var='muc_open'/>
? ? <feature var='muc_unmoderated'/>
? ? <feature var='muc_nonanonymous'/>
? ? <x xmlns='jabber:x:data' type='result'>
? ? ? <field var='FORM_TYPE' type='hidden'>
? ? ? ? <value>http://jabber.org/protocol/muc#roominfo</value>
? ? ? </field>
? ? ? <field var='muc#roominfo_description' label='Description'>
? ? ? ? <value>The place for all good witches!</value>
? ? ? </field>
? ? ? <field var='muc#roominfo_changesubject' label='Whether Occupants May Change the Subject'>
? ? ? ? <value>true</value>
? ? ? </field>
? ? ? <field var='muc#roominfo_contactjid' label='Contact Addresses'>
? ? ? ? <value>crone1@shakespeare.lit</value>
? ? ? </field>
? ? ? <field var='muc#roominfo_subject' label='Subject'>
? ? ? ? <value>Spells</value>
? ? ? </field>
? ? ? <field var='muc#roomconfig_changesubject' label='Subject can be modified'>
? ? ? ? <value>true</value>
? ? ? </field>
? ? ? <field var='muc#roominfo_occupants' label='Number of occupants'>
? ? ? ? <value>3</value>
? ? ? </field>
? ? ? <field var='muc#roominfo_ldapgroup' label='Associated LDAP Group'>
? ? ? ? <value>dc=lit,dc=shakespeare,cn=witches</value>
? ? ? </field>
? ? ? <field var='muc#roominfo_lang' label='Language of discussion'>
? ? ? ? <value>en</value>
? ? ? </field>
? ? ? <field var='muc#roominfo_logs' label='URL for discussion logs'>
? ? ? ? <value>http://www.shakespeare.lit/chatlogs/darkcave/</value>
? ? ? </field>
? ? ? <field var='muc#roominfo_pubsub' label='Associated pubsub node'>
? ? ? ? <value>xmpp:pubsub.shakespeare.lit?;node=the-darkcave-node</value>
? ? ? </field>
? ? </x>
? </query>
</iq>
? ?

Some extended room information may be dynamically generated (e.g., the URL for discussion logs, which may be based on service-wide configuration). Other information may be based on the room configuration, which is why any field defined for the?muc#roomconfig FORM_TYPE?can be included in the extended service discovery fields (as shown above for the muc#roomconfig_changesubject field).

Note: The foregoing extended service discovery fields for the 'http://jabber.org/protocol/muc#roominfo' FORM_TYPE may be supplemented in the future via the mechanisms described in the?Field Standardization?section of this document.

?

?

6.4?Querying for Room Items

查詢房間條目

A user MAY also query a specific chat room for its associated items:

一個用戶可以詢問一個特定的聊天室的一些item

Example 9. User Queries for Items Associated with a Specific Chat Room

?

<iq from='hag66@shakespeare.lit/pda' jid
? ? id='disco4'
? ? to='darkcave@chat.shakespeare.lit' roomid
? ? type='get'>
? <query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
? ?

An implementation MAY return a list of existing occupants if that information is publicly available, or return no list at all if this information is kept private.

服務(wù)端可以返回一個房間內(nèi)的occupants的信息列表。如果這個房間時public的。

Example 10. Room Returns Disco Item Results (Items are Public)

<iq from='darkcave@chat.shakespeare.lit' roomid
? ? id='disco4'
? ? to='hag66@shakespeare.lit/pda' jid
? ? type='result'>
? <query xmlns='http://jabber.org/protocol/disco#items'>
? ? <item jid='darkcave@chat.shakespeare.lit/firstwitch'/> roomjid
? ? <item jid='darkcave@chat.shakespeare.lit/secondwitch'/> roomjid
? </query>
</iq>
? ?

Note: These <item/> elements are qualified by the disco#items namespace, not the muc namespace; this means that they cannot possess 'affiliation' or 'role' attributes, for example.

item節(jié)包含在disco#items這個xmlns里面,不是muc,是因為不能有affiliation和role這些屬性。比如可以返回空。

Example 11. Room Returns Empty Disco Item Results (Items are Private)

<iq from='darkcave@chat.shakespeare.lit' roomid
? ? id='disco4'
? ? to='hag66@shakespeare.lit/pda' jid
? ? type='result'>
? <query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
? ?

6.5?Querying a Room Occupant


查詢一個房間的occupant

If a non-occupant attempts to send a disco request to an address of the form <room@service/nick>, a MUC service SHOULD return the request to the entity and specify a <bad-request/> error condition. If an occupant sends such a request, the service MAY pass it through the intended recipient; see the?Implementation Guidelines?section of this document for details.

non-occupant 試圖發(fā)disco請求給一個room會被駁回。

6.6?Discovering Client Support for MUC

查詢用戶對muc的支持

A Jabber user may want to discover if one of the user's contacts supports the Multi-User Chat protocol. This is done using Service Discovery.

一個jabber用戶或許想查詢其他的用戶是否支持muc的聊天協(xié)議

Example 12. User Queries Contact Regarding MUC Support

<iq from='hag66@shakespeare.lit/pda' jid
? ? id='disco5'
? ? to='wiccarocks@shakespeare.lit/laptop' jid
? ? type='get'>
? <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
? ?

The client SHOULD return its identity and the features it supports:

客戶端應(yīng)該返回其是否支持群聊協(xié)議

Example 13. Contact Returns Disco Info Results

<iq from='wiccarocks@shakespeare.lit/laptop'
? ? id='disco5'
? ? to='hag66@shakespeare.lit/pda'
? ? type='result'>
? <query xmlns='http://jabber.org/protocol/disco#info'>
? ? <identity
? ? ? ? category='client'
? ? ? ? type='pc'/>
? ? ...
? ? <feature var='http://jabber.org/protocol/muc'/>
? ? ...
? </query>
</iq>
? ?

A user may also query a contact regarding which rooms the contact is in. This is done by querying the contact's full JID (<user@host/resource>) while specifying the well-known Service Discovery node 'http://jabber.org/protocol/muc#rooms':

一個用戶也可能想知道另外一個用戶都在那些房間。包含muc#rooms

Example 14. User Queries Contact for Current Rooms

<iq from='hag66@shakespeare.lit/pda' jid
? ? id='rooms1'
? ? to='wiccarocks@shakespeare.lit/laptop' jid
? ? type='get'>
? <query xmlns='http://jabber.org/protocol/disco#items'
? ? ? ? ?node='http://jabber.org/protocol/muc#rooms'/>
</iq>
? ?

Example 15. Contact Returns Room Query Results

<iq from='wiccarocks@shakespeare.lit/laptop' jid
? ? id='rooms1'
? ? to='hag66@shakespeare.lit/pda' jid
? ? type='result'>
? <query xmlns='http://jabber.org/protocol/disco#items'
? ? ? ? ?node='http://jabber.org/protocol/muc#rooms'>
? ? <item jid='darkcave@chat.shakespeare.lit'/> item
? ? <item jid='characters@conference.shakespeare.lit'/>
? </query>
</iq>
? ?

Optionally, the contact MAY include its roomnick as the value of the 'name' attribute:

也可以攜帶用戶昵稱返回。

? ? ...
? ? <item jid='darkcave@chat.shakespeare.lit'
? ? ? ? ? name='secondwitch'/>
? ? ...

轉(zhuǎn)載于:https://www.cnblogs.com/lihaibo-Leao/p/3772829.html

總結(jié)

以上是生活随笔為你收集整理的xmpp muc 群聊协议 3的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。