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='hag66@shakespeare.lit/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='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

发现房间

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

服务器返回disco item 的结果

<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.

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

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 协议,用户也可以查询一个指定的房间的信息,一个用户应该在进入一个房间之前来确定这个房间的隐私和安全配置 

 

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).

应该返回一些有用的支持特征。 比如是否是密码房间,是否是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.

服务端可以返回一个房间内的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节包含在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 试图发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='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:

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

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'/>
    ...

转载于:https://www.cnblogs.com/lihaibo-Leao/p/3772829.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/407700.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Vue基础之Class和Style绑定

既然v-bind可以动态绑定标签的属性&#xff0c;那么也可以用v-bind来处理class和style&#xff0c;只需要计算出表达式最终的字符串。不过&#xff0c;字符串拼接麻烦又易错。因此&#xff0c;在 v-bind 用于 class 和 style 时&#xff0c; Vue.js 专门增强了它。表达式的结果…

Pro*c使用滚动游标进行更新或删除游标行

代码&#xff1a;xx.pc /* 功能&#xff1a;演示了Oracle滚动游标进行更新(或删除)操作定义游标时注意事项&#xff1a; 1. DECLARE CURSOR语句必须是使用游标的第一条语句 2. 游标名称是一个标识符&#xff0c;而不是宿主变量&#xff0c;其长度是可以任意的&#xff0c;但只有…

Silverlight学习笔记之使用TranslateTransform控制对象位置

在Canvas中,除了直接使用Canvas.Top与Canvas.Left属性之外,我们可以使用TextBlock.RenderTransform的TranslateTransform的X与Y属性来控制文本显示的位置。代码如下&#xff1a;<TextBlockText"Hello TranslateTransform"Canvas.Left"34" Canvas.Top&qu…

Taro+react开发(23)--componentWillReceiveProps

componentWillReceiveProps# void componentWillReceiveProps(object nextProps ) 当props发生变化时执行&#xff0c;初始化render时不执行&#xff0c; 在这个回调函数里面&#xff0c;你可以根据属性的变化&#xff0c;通过调用this.setState() 来更新你的组件状态&#xff…

MVC Area Usage

ASP.NET MVC Area操作 新建 Area&#xff1a;右键 -> Add –> Area继承 AreaRegistration&#xff0c;重写AreaName属性与RegisterArea方法 public class BookStudyAreaRegistration : AreaRegistration {public override string AreaName{get{return "BookStudy&qu…

[Pro*c]滚动游标变量的使用

代码&#xff1a;xx.pc /* 功能&#xff1a;演示了Oracle滚动游标变量的使用定义游标时注意事项&#xff1a; 1. DECLARE CURSOR语句必须是使用游标的第一条语句 2. 游标名称是一个标识符&#xff0c;而不是宿主变量&#xff0c;其长度是可以任意的&#xff0c;但只有前31个字…

css裁剪clip-path画多边形

clip-path有三种属性 第一种 circle 画圆 clip-path: circle(30%); 30%为半径大小 clip-path: circle(50% at 50% 50%); 后面的50%为圆心位置 第二种 ellipse 椭圆 clip-path: ellipse(32% 43% at 49% 50%); 32%为宽 43%为高 后面两个49%&#xff0c;50%为圆心位置 第三种 p…

教你培养成功的必备因素——强烈的企图心

企图心没有教&#xff0c;但是可以培养&#xff0c;我可以教你如何培养自己的企图心 有一次我上安东罗宾的课程&#xff0c;在夏威夷&#xff0c;安东罗宾的课程有很多世界第一名演讲&#xff0c;分享他们成为冠军的经验。安东罗宾请了一个马拉松选手&#xff0c;这个马拉松不是…

Vue基础之Vue条件渲染

v-if 在 Vue.js &#xff0c;我们使用 v-if 指令实现的功能 也可以用 v-else 添加一个 “else” 块 template-if 因为 v-if 是一个指令&#xff0c;需要将它添加到一个元素上。但是如果我们想切换多个元素呢&#xff1f;此时我们可以把一个<template>元素当做包装…

React开发(100):3.0没有image

./src/pages/Goods/Brand/index.js Module not found: Cant resolve antd/es/image in E:\shangjiahoutai\yoao-static-pc-merchant\src\pages\Goods\Brand

pro*C/C++支持c++开发实例

Pro*C/C同时支持C和C&#xff0c;但是当预编译包含C代码的PC源程序时&#xff0c;必须合理地设置相关的预编译选项。 代码&#xff1a;xx.pc /*功能&#xff1a;演示了Pro*C/C源程序生成C源文件说明&#xff1a;Pro*C/C支持C和C。当预编译包含C代码的PC源程序时&#xff0c;必…

用cocos2d-html5做的消除类游戏《英雄爱消除》(1)——系统主菜单

系统主菜单如下图所示&#xff1a; 首先&#xff0c;介绍下这个主菜单&#xff0c;它包含了一个动画logo以及一个按钮选项&#xff0c;动画logo每隔1秒钟切换一张图片&#xff0c;点击相应的按钮选项会切换不同的游戏场景。 下面看下这个界面的源码&#xff1a; /*** Power by …

推荐一篇文章,.net3.0新特性

推荐一篇文章&#xff0c;.net3.0新特性 http://www.codeproject.com/KB/cs/csharp3.aspx转载于:https://www.cnblogs.com/yukaizhao/archive/2007/12/21/net30.html

一些实用却很少用到的css以及标签

1、p:first-letter p标签里的第一个字设置样式 p:first-letter { font-size:200%; color:#8A2BE2; }<p>My best friend is Mickey.</p>2、p:first-line p标签里的设置第一行样式 3、:not&#xff08;p&#xff09; 设置非 p元素的所有元素的背景色 4、<hr>…

Vue基础之Vue列表渲染

列表渲染 我们用 v-for 指令根据一组数组的选项列表进行渲染。 v-for 指令需要以 item in items 形式的特殊语法&#xff0c; items 是源数据数组并且 item 是数组元素迭代的别名 基本用法&#xff1a; 在 v-for 块中&#xff0c;我们拥有对父作用域属性的完全访问权限。 v-f…

Pro*c使用指示变量来处理NULL列值

代码&#xff1a;xx.pc /* 功能&#xff1a;演示了Oracle使用指示变量(专门用来处理NULL值)指示变量专门用于处理数据库的NULL值&#xff0c;它是一种short类型的C语言变量。当执行内嵌SELECT语句或FETCH语句时&#xff0c;如果不引用指示变量&#xff0c;并且返回值为NULL&am…

React开发(101):样式处理

{title: 品牌信息,dataIndex: intro,render: (text, row) > {return (<div><div style{{ float: left }}><img src{row.logo} style{{ width: 100px, height: 100px }} /></div><div style{{ float: left, marginLeft: 24px }}><p>{row…

三 JSP 技术

一 JSP 概述 1. 本质&#xff1a;在 HTML 语言中混合 Java 程序代码&#xff0c;由服务器端 Java 语言引擎解释执行。其中&#xff0c;HTML 负责描述信息显示格式&#xff0c;JSP 负责描述处理逻辑。 2. JSP 代码运行环境&#xff1a;需要系统安装 JSP 引擎&#xff0c;最常用的…

Don't Laugh!I'm An English Book笔记(五)——面部词语大总结加补充

head hairscalp&#xff1a;头皮dandruff&#xff1a;头皮屑braincerebral deathforeheadwrinkleeyebroweyelideyeeyelashcrows feetdouble eyelidnosesnub nose strawberry noseaquiline nosenostrilvibrissa&#xff1a;鼻毛cheek earearlobe&#xff1a;耳唇facial hairmous…

vue 3D旋转木马轮播图

利用carousel-3d插件。 安装 npm install -S vue-carousel-3d全局引入 import Vue from vue import Carousel3d from vue-carousel-3d Vue.use(Carousel3d&#xff09;局部引入 import { Carousel3d, Slide } from "vue-carousel-3d";export default {components:…