Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>@poke asked for a little more regarding my comment.</p> <p>The first way that people tend to do device identification is to encode the device name into the resource portion of the JIDs used by that device, such as <code>joe@example.com/MYCLIENT</code> or <code>joe@example.com/MYCLIENT_[random string]</code>, then do string matching on the resource. This will appear to work for a while, until you need to write another client for a different device, at which point, you've probably encoded both <em>identity</em> of the client as well as the <em>features</em> of that client into the resource string, and stuff starts to get tough.</p> <p>A much better solution is to use <a href="http://xmpp.org/extensions/xep-0115.html" rel="nofollow">XEP-0115</a>. Read the How-it-works section <strong>very</strong> carefully. It is a confusing idea to most people the first time they read it. Summary:</p> <pre><code>&lt;presence from='romeo@montague.lit/orchard'&gt; &lt;c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://code.google.com/p/exodus' ver='QgayPKawpkPSDYmwT/WM94uAlu0='/&gt; &lt;/presence&gt; </code></pre> <p>When a contact sends presence, she adds a capabilities tag, which includes a node name, which is just a URI you make up that describes your client. That URI can be used to select an icon, or there's another approach we'll get to.</p> <p>Next, you ask the sender what that icky ver string means:</p> <pre><code>&lt;iq from='juliet@capulet.lit/chamber' id='disco1' to='romeo@montague.lit/orchard' type='get'&gt; &lt;query xmlns='http://jabber.org/protocol/disco#info' node='http://code.google.com/p/exodus#QgayPKawpkPSDYmwT/WM94uAlu0='/&gt; &lt;/iq&gt; </code></pre> <p>And then you <strong>CACHE</strong> the result:</p> <pre><code>&lt;iq from='romeo@montague.lit/orchard' id='disco1' to='juliet@capulet.lit/chamber' type='result'&gt; &lt;query xmlns='http://jabber.org/protocol/disco#info' node='http://code.google.com/p/exodus#QgayPKawpkPSDYmwT/WM94uAlu0='&gt; &lt;identity category='client' name='Exodus 0.9.1' type='pc'/&gt; &lt;feature var='http://jabber.org/protocol/caps'/&gt; &lt;feature var='http://jabber.org/protocol/disco#info'/&gt; &lt;feature var='http://jabber.org/protocol/disco#items'/&gt; &lt;feature var='http://jabber.org/protocol/muc'/&gt; &lt;/query&gt; &lt;/iq&gt; </code></pre> <p>After doing some normalization, you can SHA1-hash that result, and ensure that the hash matches the icky ver string. Now, anyone who gives you that hash, you know their capabilities. If you need to specify non-standard capabilities, just make up your own URIs to describe them, and add a feature to your caps.</p> <p>Finally, if you don't want to run around modifying all of your clients when you add a new client to your mix, you can include an extension in your caps that just specifies a URL for the client icon. <a href="http://xmpp.org/extensions/xep-0232.html" rel="nofollow">XEP-0232</a> (which is deferred, but that can't stop you from using it if you want, and can be resurrected if someone got excited about it) suggests:</p> <pre><code>&lt;iq from='juliet@capulet.lit/chamber' to='romeo@montague.lit/orchard' id='disco1' type='result'&gt; &lt;query xmlns='http://jabber.org/protocol/disco#info' node='http://code.google.com/p/exodus#RnWHG/MCjSwxZCk+p2kuN7i9kzo='&gt; &lt;x xmlns='jabber:x:data' type='result'&gt; &lt;field var='FORM_TYPE' type='hidden'&gt; &lt;value&gt;urn:xmpp:dataforms:softwareinfo&lt;/value&gt; &lt;/field&gt; &lt;field var='icon'&gt; &lt;media xmlns='urn:xmpp:media-element' height='80' width='290'&gt; &lt;uri type='image/jpeg'&gt;http://www.shakespeare.lit/clients/exodus.jpg&lt;/uri&gt; &lt;uri type='image/jpeg'&gt;cid:sha1+f24030b8d91d233bac14777be5ab531ca3b9f102@bob.xmpp.org&lt;/uri&gt; &lt;/media&gt; &lt;/field&gt; &lt;/x&gt; &lt;/query&gt; &lt;/iq&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload