zoukankan      html  css  js  c++  java
  • 简单的XMPP服务器与客户端交互

    由客户端发起

    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

  • 相关阅读:
    Beta 冲刺day 6
    Beta冲刺day5
    Beta冲刺day4
    Beta 冲刺day3
    Beta 冲刺day2
    Beta冲刺day1
    Beta预备
    城市安全风险管理项目Postmortem结果
    项目总结
    Alpha冲刺置顶随笔
  • 原文地址:https://www.cnblogs.com/zbw911/p/3673833.html
Copyright © 2011-2022 走看看