xmpp muc 群聊协议 3

6. Entity Use Cases


A MUC implementation MUST support Service
Discovery
 [7].

服务端必须实现 service discover

6.1 Discovering
Component Support for MUC

发现服务器是否支持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实体会去询问服务器,是否服务器端支持muc的协议。

例子1 : 用户向服务器询问是否支持muc的协议

iq get 协议 xmlns = "http://jabber.org/protocol/disco#info"

<iq from=‘[email protected]/pda‘ fuul jid
    id=‘disco1‘
    to=‘chat.shakespeare.lit‘ 服务器
    type=‘get‘>
  <query xmlns=‘http://jabber.org/protocol/disco#info‘/>
</iq>
   

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

服务器必须返回是否支持muc群聊

Example 2. Service Returns Disco Info
Results

<iq from=‘chat.shakespeare.lit‘ 服务器
    id=‘disco1‘
    to=‘[email protected]/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

发现房间

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=‘[email protected]/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

服务器返回disco item 的结果

<iq from=‘chat.shakespeare.lit‘ server
    id=‘disco2‘
    to=‘[email protected]/pda‘ jid
    type=‘result‘>
  <query xmlns=‘http://jabber.org/protocol/disco#items‘>
    <item jid=‘[email protected]‘
          name=‘A Lonely Heath‘/>
    <item jid=‘[email protected]‘
          name=‘A Dark Cave‘/>
    <item jid=‘[email protected]‘
          name=‘The Palace‘/>
    <item jid=‘[email protected]‘
          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.

如果全部房间列表太长,服务器可以返回一部分房间列表。如果这样做了,服务器返回的内容应该包含一个set节点,代表返回的列表不是全部列表

Example 5. Service Returns Limited
List of Disco Item Results

<iq from=‘rooms.shakespeare.lit‘ server
    id=‘disco-rsm-1‘
    to=‘[email protected]/pda‘jid
    type=‘result‘>
  <query xmlns=‘http://jabber.org/protocol/disco#items‘>
    <item jid=‘[email protected]‘/> itmes
    <item jid=‘[email protected]‘/>
    <item jid=‘[email protected]‘/>
    <item jid=‘[email protected]‘/>
    <item jid=‘[email protected]‘/>
    <item jid=‘[email protected]‘/>
    <item jid=‘[email protected]‘/>
    <item jid=‘[email protected]‘/>
    <item jid=‘[email protected]‘/>
    <item jid=‘[email protected]‘/>
    <set xmlns=‘http://jabber.org/protocol/rsm‘>
      <first index=‘0‘>[email protected]</first>
      <last>[email protected]</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 协议,用户也可以查询一个指定的房间的信息,一个用户应该在进入一个房间之前来确定这个房间的隐私和安全配置

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

<iq from=‘[email protected]/pda‘ jid
    id=‘disco3‘
    to=‘[email protected]‘ 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=‘[email protected]‘ roomid
    id=‘disco3‘
    to=‘[email protected]/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).

应该返回一些有用的支持特征。 比如是否是密码房间,是否是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=‘[email protected]‘
    id=‘disco3a‘
    to=‘[email protected]/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>[email protected]</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=‘[email protected]/pda‘ jid
    id=‘disco4‘
    to=‘[email protected]‘ 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.

服务端可以返回一个房间内的occupants的信息列表。如果这个房间时public的。

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

<iq from=‘[email protected]‘ roomid
    id=‘disco4‘
    to=‘[email protected]/pda‘ jid
    type=‘result‘>
  <query xmlns=‘http://jabber.org/protocol/disco#items‘>
    <item jid=‘[email protected]/firstwitch‘/> roomjid
    <item jid=‘[email protected]/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节包含在disco#items这个xmlns里面,不是muc,是因为不能有affiliation和role这些属性。比如可以返回空。

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

<iq from=‘[email protected]‘ roomid
    id=‘disco4‘
    to=‘[email protected]/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
<[email protected]/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
试图发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的聊天协议

Example 12. User Queries Contact
Regarding MUC Support

<iq from=‘[email protected]/pda‘ jid
    id=‘disco5‘
    to=‘[email protected]/laptop‘ jid
    type=‘get‘>
  <query xmlns=‘http://jabber.org/protocol/disco#info‘/>
</iq>
   

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

客户端应该返回其是否支持群聊协议

Example 13. Contact Returns Disco
Info Results

<iq from=‘[email protected]/laptop‘
    id=‘disco5‘
    to=‘[email protected]/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 (<[email protected]/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=‘[email protected]/pda‘ jid
    id=‘rooms1‘
    to=‘[email protected]/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=‘[email protected]/laptop‘ jid
    id=‘rooms1‘
    to=‘[email protected]/pda‘ jid
    type=‘result‘>
  <query xmlns=‘http://jabber.org/protocol/disco#items‘
         node=‘http://jabber.org/protocol/muc#rooms‘>
    <item jid=‘[email protected]‘/> item
    <item jid=‘[email protected]‘/>
  </query>
</iq>
   

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

也可以携带用户昵称返回。

    ...
    <item jid=‘[email protected]‘
          name=‘secondwitch‘/>
    ...

时间: 2024-10-13 13:08:22

xmpp muc 群聊协议 3的相关文章

xmpp muc 群聊协议 4

7. Occupant Use Cases The main actor in a multi-user chat environment is the occupant, who can be said to be located "in" a multi-user chat room and to participate in the discussions held in that room (for the purposes of this specification, par

xmpp muc 群聊协议 1

翻译来自 :http://wiki.jabbercn.org/index.php?title=XEP-0045&variant=zh-cn#.E6.9C.AF.E8.AF.AD 通用术语 Affiliation(岗位) -- 一个长期存在的和房间之间的联系或连接; 可能的岗位有 "owner"(所有者), "admin"(管理者), "member"(成员), 以及 "outcast"(被排斥者) (当然也可能没有岗位

群聊协议

互动部分协议 流程描述 建立群: 1.客户端去发请求->服务器(我们的协议810) 2.服务器端用管理员xmpp账号建群,并在服务器端记录此账号为群主 3.服务器用管理员xmpp账号发xmpp消息回来,告知群建立成功. 退出群: 1.客户端发请求->服务器(我们的协议812) 2.服务器端从数据库删掉该用户在群里的关系 3.客户端本地发送消息给xmpp服务器,并从本地删除数据.(即使没有删除成功,下次登录群列表也没有该群了) 邀请用户进入: 1.群管理人员使用客户端发请求->服务器(我们

Strophe.js连接XMPP服务器Openfire、Tigase实现Web私聊、群聊(MUC)

XMPP(Extensible Messaging and Presence Protocol)是一种网络即时通讯协议,它基于XML,具有很强的扩展性,被广泛使用在即时通讯软件.网络游戏聊天.Web聊天及Web消息推送.移动设备的消息推送等场景,例如Google的GTalk.<英雄联盟LOL>游戏聊天模块. 由于在Web浏览器上的JavaScript不能直接处理TCP协议,所以XMPP服务器通常会提供BOSH(Bidirectional-streams Over Synchronous HTT

如何解决群聊(MUC)聊天室重复存储、接收自己发送的消息的问题

CHENYILONG Blog 如何#解决方案#群聊(MUC)聊天室重复存储.接收自己发送的消息 编号 项目 描述 1 问题描述 单聊没问题,群聊会出现自动回复的问题 数据库中存储的数据出现的问题 界面上出现的问题:类似自动回复.回音壁一样一模一样地回答.  2 问题产生的原因 3 群聊基本的原理示意图 聊天内容的显示是经由从数据库进行的读取排序, 4 #解决方案# 拦截阻挡红色区域的执行  5 失败的尝试:尝试但是没有效果的方法 // AppDelegate.m中#pragma 接收消息代理监

Java--&gt;实现群聊功能(C/S模式--TCP协议)

--> Java 对TCP协议的支持: --> java.net包中定义了两个类ServerSocket 和Socket ,分别用来实现双向连接的server 端和client 端. --> Client 类定义客户端 package com.dragon.java.tcpchat; import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; /** * 客户端 * *

XMPP仅借助openfire实现群聊的流程图

其实这种搭建临时聊天室的策略有种"中病毒"的意思,就好比我QQ给你发了一个exe然后你中毒了一样.我们给需要添加进聊天室的小伙伴们统一发送一条消息,同时为消息添加一个结点(相当于exe病毒),上面绑定者我们手动输入的聊天室的名字以及随之而产生的RoomJid,对方用户只要接收到就会被添加进聊天组. 其中的原因在于我们可以很便捷无误地向其他用户发送离线消息,但是离线邀请却不一定能准确送达,必须是用户在线情况下才能收到. XMPP仅借助openfire实现群聊的流程图,布布扣,bubuko

使用java做一个能赚钱的微信群聊机器人(2020年基于PC端协议最新可用版)

前言 微信群机器人,主要用来管理群聊,提供类似天气查询.点歌.机器人聊天等用途. 由于微信将web端的协议封杀后,很多基于http协议的群聊机器人都失效了,所以这里使用基于PC端协议的插件来实现. 声明以下过程只用于交流学习,并不用于任何商业用途,这里记录一下整体的开发流程. 效果展示 接入过程 准备材料 下文中的服务器可以只需要一台,或者使用你本地电脑,我介绍一下我的环境. 可爱猫微信机器人插件V4.4.0. 一台windows服务器. 一台linux服务器. nginx安装(在window服

群聊

XMPP在其XEP-0045扩展中定义了一个用于多用户文本会议(群聊)的协议,类似于聊天室.QQ群等.由于它作为一个标准协议在定义模型上力求完备,涵盖了现实中的绝大部分IM产品模型,而现实中的IM产品基本都只实现了XMPP定义的模型中的一个子集.XMPP定义的一些基本概念:房间:房间的JID标识 <[email protected]> (例如, <[email protected]>), 这里 "room" 是房间的名称而 "service"