• Feeds

  • disco#info, service discovery 发现服务 XEP-0030

    总结一下,XEP-0030 (前JEP-0030) disco#info 3个主要用途:

    1. 查询服务器
    <iq from=’tim@timpc/home’ to=’timpc’>
    <query xmlns=’http://jabber.org/disco#info’/>
    </iq>

    目标主机必须返回一个IQ结果或错误。
    返回结果的 <query/> 必须标明 ‘http://jabber.org/protocol/disco#info’ namespace,含有一到多个 <identity/> 一到多个 <feature/> elements.

    Note: Every entity MUST have at least one identity, and every entity MUST support at least the ‘http://jabber.org/protocol/disco#info’ feature; however, an entity is not required to return a result and MAY return an error, most likely <feature-not-implemented/> or <service-unavailable/>, although other error conditions may be appropriate.

    每个 <identity/> 里面必须包含 ‘category’ and ‘type’, 并可以加上一个友好的名称 ‘name’
    每个 <feature/> 必须包含 ‘var’ protocol namespace or other feature offered by the entity.category/type 最好是存在一个注册表里面

    2. 查询某个JID
    当一个 disco#info 发送到一个普通用户JID时候,JID的服务器必须直接返回结果,不过我看不出这个请求有多大的实际用途。JEP的例子说应答服务器在确认请求方是可以信任的前提下可以返回这个用户是否注册。

    向服务器查询 juliet@capulet.com 的 disco#info
    &lt;iq type='get'
    from='shakespeare.lit'
    to='juliet@capulet.com'
    id='info2'&gt;
    &lt;query xmlns='http://jabber.org/protocol/disco#info'/&gt;
    &lt;/iq&gt;

    服务器应答 registered account
    &lt;iq type='result'
    from='juliet@capulet.com'
    to='shakespeare.lit'
    id='info2'&gt;
    &lt;query xmlns='http://jabber.org/protocol/disco#info'&gt;
    &lt;identity category='account' type='registered'/&gt;
    &lt;/query&gt;
    &lt;/iq&gt;

    也可以应答当前用户连接的 resource 的信息
    &lt;iq type='get'
    from='juliet@capulet.com/balcony'
    to='timyang@jabber.org/orchard'
    id='info4'&gt;
    &lt;query xmlns='http://jabber.org/protocol/disco#info'/&gt;
    &lt;/iq&gt;

    <iq type=’result’
    from=’timyang@jabber.org/orchard’
    to=’juliet@capulet.com/balcony’
    id=’info4′>
    <query xmlns=’http://jabber.org/protocol/disco#info’>
    <identity
    category=’client’
    type=’pc’
    name=’Gabber’/>
    <feature var=’jabber:iq:time’/>
    <feature var=’jabber:iq:version’/>
    </query>
    </iq>

    3. 查询 conference room (muc)
    <iq type=’get’
    from=’juliet@capulet.com/balcony’
    to=’balconyscene@plays.shakespeare.lit’
    id=’info3′>
    <query xmlns=’http://jabber.org/protocol/disco#info’/>
    </iq>

    <iq type=’result’
    from=’balconyscene@plays.shakespeare.lit’
    to=’juliet@capulet.com/balcony’
    id=’info3′>
    <query xmlns=’http://jabber.org/protocol/disco#info’>
    <identity
    category=’conference’
    type=’text’
    name=’Romeo and Juliet, Act II, Scene II’/>
    <feature var=’http://jabber.org/protocol/disco#info’/>
    <feature var=’http://jabber.org/protocol/muc’/>
    <feature var=’http://jabber.org/protocol/feature-neg’/>
    <feature var=’muc-password’/>
    <feature var=’muc-hidden’/>
    <feature var=’muc-temporary’/>
    <feature var=’muc-open’/>
    <feature var=’muc-unmoderated’/>
    <feature var=’muc-nonanonymous’/>
    </query>
    </iq>

    如想及时阅读Tim Yang的文章,可通过页面右上方扫码订阅最新更新。

    « | »

    4 Comments  »

    1. Ishan

      nice

    2. My goodness, artists were so talented in the past and today… Damn…

    3. Games are kind of dangerous, on one hand they are entertaining and fun, but on the other hand they can be addicting and take a lot of our time.

    Leave a Comment