标签:告诉 pac XML nav ros adc 自己 请求报文 color
Presence.Type有七种 available (默认)用户空闲状态,即在线 unavailable 用户没空看消息,即离线 subscribe 请求订阅别人,即请求加对方为好友 subscribed 统一被别人订阅,也就是确认被对方加为好友 unsubscribe 他取消订阅别人,请求删除某好友 unsubscribed 拒绝被别人订阅,即拒绝对方的添加请求 error -- 当前状态packet有错误 好友双方对彼此的状态,有网友总结如下: none:是用户和自己roster中的好友彼此不关心,既不想把自己的presence状态告诉对方,也不愿意收到对方presence更新消息 to:知道别人的出席消息,而别人不知道自己的出席信息 from:别人知道自己的出席信息, 但自己不知道别人的出席信息 Both:即收取对方状态更新,又将自己的更新告知对方 Remove :将对方干掉,不再关心他的任何信息。 zxl1添加zxl2,加到Friends组,备注zxl2,C:client S:server zxl1向zxl2发送添加请求Presence.Type.subscribe 订阅关系:none zxl1->C: <iq id="zR0f2-29" type="set"> <query xmlns="jabber:iq:roster"> <item jid="zxl2@user-20160421db" name="zxl2"> <group>Friends</group> </item> </query> </iq> S: <iq type="set" id="632-3020" to="zxl1@user-20160421db/Spark"> <query xmlns="jabber:iq:roster"> <item jid="zxl2@user-20160421db" name="zxl2" subscription="none"> <group>Friends</group> </item> </query> </iq> zxl1->C:TCP S:<iq type="result" id="zR0f2-29" to="zxl1@user-20160421db/Spark"/> zxl1-> C: <presence id="zR0f2-30" to="zxl2@user-20160421db" type="subscribe"> <x xmlns="vcard-temp:x:update"> <photo>ba8c94a333af7a23d9e44c41b2aa22dd2224dadc</photo> </x> <x xmlns="jabber:x:avatar"> <hash>ba8c94a333af7a23d9e44c41b2aa22dd2224dadc</hash> </x> </presence> S: <iq type="set" id="331-3022" to="zxl1@user-20160421db/Spark"> <query xmlns="jabber:iq:roster"> <item jid="zxl2@user-20160421db" name="zxl2" ask="subscribe" subscription="none"> <group>Friends</group> </item> </query> </iq> zxl1->C:TCP 之后就分为3个场景 场景一:zxl2收到zxl1的请求,拒绝zxl1 订阅关系:none S: <presence id="SIuGQ-28" to="zxl1@user-20160421db" type="unsubscribe"> <x xmlns="vcard-temp:x:update"> <photo>a76bac95d8fe05fb3df6142bc5cac14ce660345d</photo> </x> <x xmlns="jabber:x:avatar"> <hash>a76bac95d8fe05fb3df6142bc5cac14ce660345d</hash> </x> </presence> 场景二:zxl2收到zxl1的请求,zxl2答应,zxl1拒绝 1.zxl2收到zxl1的请求,zxl2答应 订阅关系:zxl1:from zxl2:to C: <iq id="A7O3Y-27" type="get"> <ping xmlns=‘urn:xmpp:ping‘ /> </iq> S: <iq type="result" id="A7O3Y-27" to="zxl2@user-20160421db/Spark"/> C: TCP C: <iq id="A7O3Y-28" type="set"> <query xmlns="jabber:iq:roster"> <item jid="zxl1@user-20160421db" name=""> <group>Friends</group> </item> </query> </iq> S: <iq type="set" id="971-3086" to="zxl2@user-20160421db/Spark"> <query xmlns="jabber:iq:roster"> <item jid="zxl1@user-20160421db" name="" subscription="from"> <group>Friends</group> </item> </query> </iq> C: TCP S: <iq type="result" id="A7O3Y-28" to="zxl2@user-20160421db/Spark"/> C: <presence id="A7O3Y-29" to="zxl1@user-20160421db" type="subscribe"> <x xmlns="vcard-temp:x:update"> <photo>a76bac95d8fe05fb3df6142bc5cac14ce660345d</photo> </x> <x xmlns="jabber:x:avatar"> <hash>a76bac95d8fe05fb3df6142bc5cac14ce660345d</hash> </x> </presence> S: <iq type="set" id="505-3088" to="zxl2@user-20160421db/Spark"> <query xmlns="jabber:iq:roster"> <item jid="zxl1@user-20160421db" name="" ask="subscribe" subscription="from"> <group>Friends</group> </item> </query> </iq> C: <presence id="A7O3Y-30" to="zxl1@user-20160421db" type="subscribed"> <x xmlns="vcard-temp:x:update"> <photo>a76bac95d8fe05fb3df6142bc5cac14ce660345d</photo> </x> <x xmlns="jabber:x:avatar"> <hash>a76bac95d8fe05fb3df6142bc5cac14ce660345d</hash> </x> </presence> S: TCP 2.zxl1添加zxl2,zxl2答应,zxl1拒绝 zxl1:to zxl2:from C: <presence id="RIdep-27" to="zxl2@user-20160421db" type="unsubscribe"> <x xmlns="vcard-temp:x:update"> <photo>ba8c94a333af7a23d9e44c41b2aa22dd2224dadc</photo> </x> <x xmlns="jabber:x:avatar"> <hash>ba8c94a333af7a23d9e44c41b2aa22dd2224dadc</hash> </x> </presence> S: <iq type="set" id="278-3097" to="zxl1@user-20160421db/Spark"> <query xmlns="jabber:iq:roster"> <item jid="zxl2@user-20160421db" name="zxl2" ask="unsubscribe" subscription="from"> <group>Friends</group> </item> </query> </iq> C: TCP C: <iq id="RIdep-28" type="get"><ping xmlns=‘urn:xmpp:ping‘ /></iq> S: <iq type="result" id="RIdep-28" to="zxl1@user-20160421db/Spark"/> C: TCP C: <iq id="RIdep-29" type="get"><ping xmlns=‘urn:xmpp:ping‘ /></iq> S: <iq type="result" id="RIdep-29" to="zxl1@user-20160421db/Spark"/> C: TCP C: <iq id="RIdep-30" type="get"><ping xmlns=‘urn:xmpp:ping‘ /></iq> S: <iq type="result" id="RIdep-30" to="zxl1@user-20160421db/Spark"/> C: TCP 场景三:zxl1添加zxl2,zxl2答应,zxl1答应,两者关系both zxl2收到zxl1的请求,zxl2答应 订阅关系:zxl1:from zxl2:to 同场景二的第1步 zxl1添加zxl2,zxl2答应,zxl1答应 ,订阅关系:both C: <presence id="gGoyI-33" to="zxl2@user-20160421db" type="subscribed"> <x xmlns="vcard-temp:x:update"> <photo>d502a48d3e02f421269f9b1393c1f0cd825a8e4f</photo> </x> <x xmlns="jabber:x:avatar"> <hash>d502a48d3e02f421269f9b1393c1f0cd825a8e4f</hash> </x> </presence> S: <iq type="set" id="456-431" to="zxl1@user-20160421db/Spark"> <query xmlns="jabber:iq:roster"> <item jid="zxl2@user-20160421db" name="zxl2" subscription="both"> <group>Friends</group> </item> </query> </iq>
标签:告诉 pac XML nav ros adc 自己 请求报文 color
原文地址:http://www.cnblogs.com/xiaolonghome/p/6648984.html