由客户端发起
C: <stream:stream to="localhost" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
服务器开始响应
S:<stream:stream from='localhost' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='1959'>
验证请求
C:
<iq id="8AUK4-0" type="get">
<query xmlns="jabber:iq:auth">
<username>2</username>
</query>
</iq>
协商协议
S:
<iq id="8AUK4-0" to="localhost" type="result">
<query xmlns="jabber:iq:auth">
<username>2</username>
<password/>
</query>
</iq>
登录包
C:
<iq id="8AUK4-1" type="set">
<query xmlns="jabber:iq:auth">
<username>2</username>
<password>2</password>
<resource>Spark 2.6.3</resource>
</query>
</iq>
登录成功结果
S:
<iq id="8AUK4-1" from="localhost" type="result"/>
取得好友名单
C:
<iq id="8AUK4-2" type="get">
<query xmlns="jabber:iq:roster"/>
</iq>
返回名单
S:
<iq id="8AUK4-2" to="2@localhost/Spark 2.6.3" type="result">
<query xmlns="jabber:iq:roster">
<item jid="1@localhost" name="张三" subscription="both">
<group>Friends</group>
</item>
<item jid="3@localhost" name="3@localhost" subscription="none" ask="subscribe">
<group>Friends</group>
</item>
</query>
</iq>
C:
<iq id="8AUK4-3" to="localhost" type="get">
<query xmlns="http://jabber.org/protocol/disco#items"/>
</iq>
S:
<iq id="8AUK4-3" to="2@localhost/Spark 2.6.3" from="localhost" type="result">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="conference.localhost" name="Chatroom Service"/>
</query>
</iq>
C: 表示client
S: 表示Server