XMPP客户端关于用户组和好友列表的管理的一个实现方法
2011-09-30 09:05
621 查看
groupmanagement
由于XMPP协议并没有很好的支持group,也就是说,client没有办法从server得到空的grouplist。为了解决这个问题,用户在client创建一个group,我们会将grouplist存到server的storage:groups中。group存放的格式如下:<storagexmlns='http://jabber.com/jabber/storage:groups'> <group>Team</group> <group>TestUsers</group> <group>US</group> <group>HF</group> <group>HZ</group> <group>SZ</group> </storage>
[/code]
client每次loginserver时,首先会从storage:groups拿到一个grouplist,然后再去拿buddylist,得到buddylist以后,再将从storage:groups拿到的grouplist和buddylist中含有的grouplist做一个合并,得到一个完整的grouplist。
contactmanagement
参考<iqto='juliet@example.com/balcony'type='result'id='roster_1'> <queryxmlns='jabber:iq:roster'> <itemjid='romeo@example.net' name='Romeo' subscription='both'> <group>Friends</group> </item> <itemjid='mercutio@example.org' name='Mercutio' subscription='from'> <group>Friends</group> </item> <itemjid='benvolio@example.org' name='Benvolio' subscription='both'> <group>Friends</group> </item> </query> </iq>
[/code]
这里介绍几个概念,每个item表示一个contact(XMPP协议称为roster),nameattribute表示这个contact的friendlyname,subscription表示用户和contact之间的一个关系,RFC3921chapter8详细介绍了subscription的内容。item/group说明了这个contact归属于哪一个/几个group中,如果这个用户属于多个group,在item下就会有多个grouptag。
subscriptionstatus
Thestateofthepresencesubscriptioninrelationtoarosteritemiscapturedinthe'subscription'attribute ofthe<item/>element.Allowablevaluesforthisattributeare:
"none"--theuserdoesnothaveasubscriptiontothecontact'spresenceinformation,andthecontactdoesnot
haveasubscriptiontotheuser'spresenceinformation
"to"--theuserhasasubscriptiontothecontact'spresenceinformation,butthecontactdoesnothavea
subscriptiontotheuser'spresenceinformation
"from"--thecontacthasasubscriptiontotheuser'spresenceinformation,buttheuserdoesnothavea
subscriptiontothecontact'spresenceinformation
"both"--boththeuserandthecontacthavesubscriptionstoeachother'spresenceinformation
上面的定义来自
none表示用户和contact之前没有任何的关系(虽然在server的buddylist中存在);
to表示用户能看到contact的presence,但是contact看不到用户的Presence;
from和to的含义相反,指用户看不到contact的presence,但是contact可以看到;
both表示相关之间都能看到对方的presence。
除了上面定义的subscription之外,还有一个相关的状态:subscriptionrequest;outsubscriptionrequest可以在contact的item中体现出来,ask='subscribe'表示用户给这个contact发送了一个subscriptionrequest;insubscriptionrequest只能在用户收到的presence中体现出来(type为subscribe)。将subscriptionrequest和上述定义的subscription
value组合起来,就会得到一个完整的subscription的状态表。
下面的enum来之.h文件的定义
//IamA,thebuddyisB
typedefenumtagConSubscriptionType
{
ConSubscription_None=0,
ConSubscription_NoneOut,//AaddB,Bhasnoresponse,SO:Bisinoutstandinginvitationgroup
ConSubscription_NoneIn,//BaddA,Ahasnoresponse,SO:Awillseerequestdialog
ConSubscription_NoneOutIn,//AaddBandBaddA,neitherresponse,SO:Awillseerequestdialog,Bisinoutstdgroup
ConSubscription_To,//AcanseeB'spresence,BcannotseeA,SO:Bisinnormalgroup
ConSubscription_ToIn,//AcanseeB'spresence,BaddA,Anoresponse,SO:Awillseerequestdialog
ConSubscription_From,//BcanseeA'spresence,SO:Bisinobservergroup
ConSubscription_FromOut,//BcanseeA'spresence,AaddB,Bnoresponse,SO:Bisinobservergroupandoutstdgroup
ConSubscription_Both,//AandBcanseeeachother'spresence,SO:Bisinnormalgroup
}ConSubscriptionType;
相关文章推荐
- XMPP客户端关于用户组和好友列表的管理的一个实现方法
- XMPP客户端关于用户组排序的一个可能的实现方法
- 用C语言关于学生管理系统的几种实现方法(一位数组,二维数组,指针,结构体)
- 如何在ASP.net中实现限制一个用户名在多个客户端IE登陆的方法
- agsXMPP客户端关于好友在线状态的设置及其响应的方法
- C语言实现一个Window控制台带彩色,且可以用方向键选择并确认的菜单式列表(二) ---学生信息管理系统
- Winform界面中实现菜单列表的动态个性化配置管理方法
- Python 最近因开发项目的需要,有一个需求,就是很多SNS网站都有的通过 Email地址 导入好友列表,不过这次要导入的不是Email 列表,而是QQ的好友列表。 实现方式: 通过goog
- 关于web中下拉列表的几种实现方法
- Android编程实现在Activity中操作刷新另外一个Activity数据列表的方法
- agsXMPP客户端关于好友在线状态的设置及其响应的方法
- 无配置WCF客户端的一个简单到令人发指的实现方法
- 一种基于im客户端实现消息图片管理的方法和装置
- Visual Studio 连接 Mysql 实现一个选课管理系统--->提取数据的几种方法
- 概述 RequireJS是一个工具库,主要用于客户端的模块管理。它可以让客户端的代码分成一个个模块,实现异步或动态加载,从而提高代码的性能和可维护性。它的模块管理遵守AMD规范(Asynchronou
- 这是一个关于XML文档的操作管理器XMLHelper类,类中包括XML文档的创建,文档节点和属性的读取,添加,修改,删除的方法功能的实现
- 实现一个内存池管理的类方法
- 关于web中下拉列表的几种实现方法
- sql server 关于表中只增标识问题 C# 实现自动化打开和关闭可执行文件(或 关闭停止与系统交互的可执行文件) ajaxfileupload插件上传图片功能,用MVC和aspx做后台各写了一个案例 将小写阿拉伯数字转换成大写的汉字, C# WinForm 中英文实现, 国际化实现的简单方法 ASP.NET Core 2 学习笔记(六)ASP.NET Core 2 学习笔记(三)