一、好友关系建立:
1、用户tom请求加 hu用户为好友
发送数据包:
<presence id="p87KM-43" to="hu@192.168.1.101" type="subscribe"></presence>
数据库状态:
2、用户hu上线,收到好友请求
收到数据包:
<presence from="tom@192.168.1.101" to="hu@192.168.1.101" type="subscribe"/>
发送数据包:
<presence id="XYK6P-11" to="tom@192.168.1.101" type="subscribed"></presence>
数据库状态:
3、用户hu同意好友请求(单向)
发送数据包:
<presence id="XYK6P-37" to="tom@192.168.1.101" type="subscribe"></presence>
<presence id="XYK6P-38" to="tom@192.168.1.101" type="subscribed"></presence>
数据库状态:
4、用户tom上线,收到同意请求,双方成为好友关系
收到数据包:
<presence from="hu@192.168.1.101" to="tom@192.168.1.101" type="subscribe"/>
发送数据包:
<presence id="an1i2-11" to="hu@192.168.1.101" type="subscribed"></presence>
数据库状态:
二、好友关系解除
1、用户tom删除用户hu 好友关系(单向)
发送数据包:
<iq id="an1i2-34" type="set"><query xmlns="jabber:iq:roster"><item jid="hu@192.168.1.101" name="hu" subscription="remove"><group>Friends</group></item></query></iq>
数据库状态:
2、用户 hu上线,移除tom用户
发送数据包:
<iq id="oIN27-35" type="set"><query xmlns="jabber:iq:roster"><item jid="tom@192.168.1.101" name="tom" subscription="remove"><group>Friends</group></item></query></iq>
数据库状态:
三、拒绝好友请求
1、用户hu请求加 tom用户为好友
发送数据包:
<presence id="1vxnM-34" to="tom@192.168.1.101" type="subscribe"></presence>
数据库状态:
2、用户tom上线,收到好友请求
收到数据包:
<presence from="hu@192.168.1.101" to="tom@192.168.1.101" type="subscribe"/>
发送数据包:
<presence id="Cdu1S-12" to="hu@192.168.1.101" type="subscribed"></presence>
数据库状态:
3、用户tom拒绝 用户hu好友申请
发送数据包:
<presence id="Cdu1S-33" to="hu@192.168.1.101" type="unsubscribe"></presence>
数据库状态:
好友花名册官方解析:
ofRoster (buddy rosters or lists)Column Name Type Length Description
rosterID | NUMBER | n/a | ID of roster (Primary Key) |
username | VARCHAR | 32 | User Name |
jid | TEXT | n/a | The address of the roster entry |
sub | NUMBER | n/a | The subscription status of the entry |
ask | NUMBER | n/a | The ask status of the entry |
recv | NUMBER | n/a | Flag indicating the entry is a roster request that was received |
nick | VARCHAR | 255 | The nickname assigned to this roster entry
|
字段的具体分析:
askstatus
-1— 没有挂起的添加好友请求。
The roster item has no pending subscription requests.
0— 有挂起的添加好友请求。
The roster item has been asked for permission to subscribe to its presence but no response has been received.
1— 估计是有没有回复的删除请求吧
The roster owner has asked the roster item to be unsubscribed from its presence notifications but hasn't yet received confi rmation.
recvstatus
-1— 已经回复添加好友请求
There are no subscriptions that have been received but not presented to the user.
1— 接收到好友请求但是没有给好友回复
The server has received a subscribe request, but has not forwarded it to the user.
2— 估计是没有回复删除请求吧
The server has received an unsubscribe request, but has not forwarded it to the user.
substatus
-1— 应该删除这个好友
Indicates that the roster item should be removed.
0— 没有建立好友关系
No subscription is established.
1— 用户已经发出好友请求
The roster owner has a subscription to the roster item’s presence.
2— 收到好友请求并且加对方好友
The roster item has a subscription to the roster owner’s presence.
3— 好友已经相互添加
The roster item and the owner have a mutual subscription.