XMPP协议摘要

来源:互联网 发布:Mac上安装anaconda 编辑:程序博客网 时间:2024/05/22 04:32

总体描述

 

一个会话以<stream>开头,</stream>结束,中间可以有任意长的信息流

 

<stream>包含的属性有'to''from''id''xml:lang'四种,用法如下
                 |  initiating to receiving     |  receiving to initiating
   -----------+-------------------------------+-----------------------
   to           |  hostname of receiver    |  silently ignored
   from       |  silently ignored              |  hostname of receiver
   id            |  silently ignored             |  session key
   xml:lang |  default language           |  default language
   version   |  signals XMPP 1.0 support |  signals XMPP 1.0 support


一级子元素只有<message/><presence/><iq/>三种

<iq>元素的使用规范

id 属性为必须,用于区别iq

type属性为必须,用于表示请求类型,有get,set,result,error四种

接收方如收到get或set必须返回result或error类型的<iq>元素来应答,里面要包含发送方请求当中的id属性

set或get请求必须要有一个且只能有一个子元素来表明请求的类型

result请求必须包含0个或1个子元素

 

错误信息
<stream:error></stream:error>之间
可以包括如下子项
<bad-format/>
<bad-namespace-prefix/>
<conflict/>
<connection-timeout/>
<host-gone/>
<host-unknown/>等

 

名字空间
<stream/>的名字空间一定是http://etherx.jabber.org/streams 

 

Roster相关操作

roster的操作包含在<query>标签里面,名字空间为jabber:iq:roster

里面可以包含一个或多个<item>子项,其属性如下

jid属性为必须,标识一个用户

name属性可选,相当于用户的昵称

subscription属性可选,不过在删除元素时有用

group属性可选,设置该用户的组别

原创粉丝点击