登录 用户中心() [退出] 后台管理 注册
 
您的位置: 首页 首页 >> SoftHub关联区 >> SoftHub关联区 >> 主题: XMPP 连接登录过程    [最新]
XMPP 连接登录过程
guest
浏览(0) - 2018-08-05 12:57:33 发表 编辑

关键字: xmpp

XMPP 连接登录过程

https://blog.csdn.net/lixiaowei16/article/details/48573839
--------------------------------------------------
XMPP 连接登录过程
2015年09月19日 11:44:48
阅读数:2125

 本文对于刚开始XMPP的学习者非常有用,初始登录过程主要包括如下基本步骤:
   1.  查询和使用TLS
   2.  查询和使用SASL并使用账户密码登录
   3.  bind资源
   4.  广播自己的出息信息并接受Server广播的出息信息
   5.  下载自己的Roster,vcard, block, disc, bookmark等信息

    ####client下线 
    <presence type="unavailable"> 
    <status>Logged out</status> 
    </presence> 

    ####client发起连接 
    <?xml version="1.0"?> 
    <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" xmlns="jabber:client" to="xumatomacbook-pro.local" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace"> 

    ####server相应并回复验证的features 
    <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='xumatomacbook-pro.local' id='675c6847-c13d-4710-9844-d9339e4df087' version='1.0' xml:lang='en'> 
     
    <stream:features> 
    <ver xmlns="urn:xmpp:features:rosterver"/> 
    <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> 
    <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> 
    <mechanism>PLAIN</mechanism> 
    <mechanism>ANONYMOUS</mechanism> 
    </mechanisms> 
    <register xmlns="http://jabber.org/features/iq-register"/> 
    <auth xmlns="http://jabber.org/features/iq-auth"/> 
    </stream:features> 

    ####client启动tls验证 
    <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> 

    ####server表示支持,可以继续 
    <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> 

    ####tls验证结束,重新开始 
    <?xml version="1.0"?> 
     
    <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" xmlns="jabber:client" to="xumatomacbook-pro.local" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace"> 

    ####server响应,并返回下一步验证支持的features,sasl 
    <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='xumatomacbook-pro.local' id='675c6847-c13d-4710-9844-d9339e4df087' version='1.0' xml:lang='en'> 
     
     
    <stream:features> 
    <ver xmlns="urn:xmpp:features:rosterver"/> 
    <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> 
    <mechanism>PLAIN</mechanism> 
    <mechanism>ANONYMOUS</mechanism> 
    </mechanisms> 
    <register xmlns="http://jabber.org/features/iq-register"/> 
    <auth xmlns="http://jabber.org/features/iq-auth"/> 
    </stream:features> 

    ####client开始sasl验证 
    <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AGd1YW5mZWkAZ3VhbmZlaQ==</auth> 

    ####server表示成功了 
    <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/> 

    ####client重新开始 
    <?xml version="1.0"?> 
     
     
    <stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" xmlns="jabber:client" to="xumatomacbook-pro.local" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace"> 

    ####server响应并返回支持的features 
    <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='xumatomacbook-pro.local' id='675c6847-c13d-4710-9844-d9339e4df087' version='1.0' xml:lang='en'> 
     
     
    <stream:features> 
    <ver xmlns="urn:xmpp:features:rosterver"/> 
    <session xmlns="urn:ietf:params:xml:ns:xmpp-session"/> 
    <register xmlns="http://jabber.org/features/iq-register"/> 
    <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/> 
    </stream:features> 

    ####client请求resource bind 
    <iq type="set" id="bind_1"> 
    <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"> 
    <resource>Psi+</resource> 
    </bind> 
    </iq> 

    ####server判断并返回结果 
    <iq xmlns="jabber:client" type="result" id="bind_1" to="guanfei@xumatomacbook-pro.local/Psi+"> 
    <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"> 
    <jid>guanfei@xumatomacbook-pro.local/Psi+</jid> 
    </bind> 
    </iq> 

    ####client发起session 
    <iq type="set" id="ab46a"> 
    <session xmlns="urn:ietf:params:xml:ns:xmpp-session"/> 
    </iq> 

    ####server端响应 
    <iq type="result" id="ab46a" to="guanfei@xumatomacbook-pro.local/Psi+"/> 

    ####client端请求roster列表 
    <iq type="get" id="ab47a"> 
    <query xmlns="jabber:iq:roster"/> 
    </iq> 

    ####server端返回 
    <iq type="result" id="ab47a" to="guanfei@xumatomacbook-pro.local/Psi+"> 
    <query xmlns="jabber:iq:roster"> 
    <item subscription="both" name="ohno" jid="guanfei1@xumatomacbook-pro.local"/> 
    </query> 
    </iq> 

    ####client广播自己的出席信息 
    <presence> 
    <priority>50</priority> 
    <c xmlns="http://jabber.org/protocol/caps" node="http://psi-dev.googlecode.com/caps" ver="0.16" ext="ca cs e-time ep-notify-2 html last-act mr sxe whiteboard"/> 
    </presence> 

    ####client请求自己的个人信息 
    <iq type="get" id="ab49a"> 
    <query xmlns="jabber:iq:privacy"/> 
    </iq> 

    ####client请求bookmark 
    <iq type="get" id="ab4aa"> 
    <query xmlns="jabber:iq:private"> 
    <storage xmlns="storage:bookmarks"/> 
    </query> 
    </iq> 

    ####client请求个人vcard 
    <iq type="get" to="guanfei@xumatomacbook-pro.local" id="ab4ba"> 
    <vCard xmlns="vcard-temp"/> 
    </iq> 

    ####client请求disco列表 
    <iq type="get" to="xumatomacbook-pro.local" id="ab4ca"> 
    <query xmlns="http://jabber.org/protocol/disco#info"/> 
    </iq> 

    ####server广播出席信息 
    <presence from="guanfei@xumatomacbook-pro.local/Psi+" to="guanfei@xumatomacbook-pro.local"> 
    <priority>50</priority> 
    <c xmlns="http://jabber.org/protocol/caps" node="http://psi-dev.googlecode.com/caps" ver="0.16" ext="ca cs e-time ep-notify-2 html last-act mr sxe whiteboard"/> 
    </presence> 

    ####server返回个人信息项列表 
    <iq type="result" id="ab49a" to="guanfei@xumatomacbook-pro.local/Psi+"> 
    <query xmlns="jabber:iq:privacy"> 
    <list name="blocked"/> 
    <default name="blocked"/> 
    <active name="blocked"/> 
    </query> 
    </iq> 

    ####client请求block项内容 
    <iq type="get" id="ab4da"> 
    <query xmlns="jabber:iq:privacy"> 
    <list name="blocked"/> 
    </query> 
    </iq> 

    ####server返回bookmark信息 
    <iq type="result" id="ab4aa" to="guanfei@xumatomacbook-pro.local/Psi+"> 
    <query xmlns="jabber:iq:private"> 
    <storage xmlns="storage:bookmarks"/> 
    </query> 
    </iq> 

    ####server返回vcard信息 
    <iq from="guanfei@xumatomacbook-pro.local" type="result" to="guanfei@xumatomacbook-pro.local/Psi+" id="ab4ba"> 
    <vCard xmlns="vcard-temp"> 
    <FN>guanfei</FN> 
    <NICKNAME>guanfei</NICKNAME> 
    </vCard> 
    </iq> 

    ####server返回disco列表 
    <iq from="xumatomacbook-pro.local" type="result" to="guanfei@xumatomacbook-pro.local/Psi+" id="ab4ca"> 
    <query xmlns="http://jabber.org/protocol/disco#info"> 
    <identity category="server" type="im" name="Tigase ver. 0.0.0-0"/> 
    <feature var="http://jabber.org/protocol/disco#info"/> 
    <feature var="http://jabber.org/protocol/disco#items"/> 
    <feature var="msgoffline"/> 
    <feature var="http://jabber.org/protocol/stats"/> 
    <feature var="http://jabber.org/protocol/commands"/> 
    <feature var="jabber:iq:version"/> 
    <feature var="jabber:iq:roster"/> 
    <feature var="jabber:iq:roster-dynamic"/> 
    <feature var="vcard-temp"/> 
    <feature var="urn:ietf:params:xml:ns:xmpp-sasl"/> 
    <feature var="urn:xmpp:ping"/> 
    <feature var="http://jabber.org/protocol/pubsub"/> 
    <feature var="http://jabber.org/protocol/pubsub#owner"/> 
    <feature var="http://jabber.org/protocol/pubsub#publish"/> 
    <identity category="pubsub" type="pep"/> 
    <feature var="urn:ietf:params:xml:ns:xmpp-session"/> 
    <feature var="http://jabber.org/protocol/amp"/> 
    <feature var="msgoffline"/> 
    <feature var="http://jabber.org/protocol/disco#info"/> 
    <feature var="http://jabber.org/protocol/disco#items"/> 
    <feature var="jabber:iq:privacy"/> 
    <feature var="urn:ietf:params:xml:ns:xmpp-bind"/> 
    <feature var="jabber:iq:private"/> 
    <feature var="jabber:iq:auth"/> 
    </query> 
    </iq> 

    <presence from="guanfei1@xumatomacbook-pro.local/Psi+" to="guanfei@xumatomacbook-pro.local"> 
    <priority>50</priority> 
    <c xmlns="http://jabber.org/protocol/caps" node="http://psi-dev.googlecode.com/caps" ver="0.16" ext="ca cs e-time ep-notify-2 html last-act mr sxe whiteboard"/> 
    </presence> 

    <iq type="result" id="ab4da" to="guanfei@xumatomacbook-pro.local/Psi+"> 
    <query xmlns="jabber:iq:privacy"> 
    <list name="blocked"> 
    <item action="allow" order="100"/> 
    </list> 
    </query> 
    </iq> 

个人分类: IM通讯
相关热词: xmpp xmpp比较 xmpp服务端 xmpp解析 xmpp压缩传输




总数:0 页次:1/0 首页 尾页  
总数:0 页次:1/0 首页 尾页  


该采集也在以下书单中



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2017 clq, All Rights Reserved
CLQ工作室 版权所有