Payload Carrier
Earlier in this chapter we saw how a basic message was embellished with
a structured and parseable “attachment” in the form of a
jabber:x:oob
-qualified <x/>
tag and its child tags:
<x xmlns='jabber:x:oob'> <url>http://www.megacorp.co.uk/earnings3q.html</url> <desc>Third Quarter Earnings for Megacorp</desc> </x>
How does this actually work in practice? Well, partly by requirement, partly by convention:
All three of the elements,
<message/>
,<iq/>
, and<presence/>
, can carry these attachments.These attachments usually serve one of two purposes:
To bring primary (or secondary) meaning to the element that contains it.
To act as the driving force behind the element, such as that the element really exists only to carry the attachment.
This distinction is rather subtle, so let’s look at a couple of examples.
Example 2-2
shows an attachment in the jabber:x:delay
namespace. This works like a timestamp and in this context indicates when
that presence element appeared—in other words, from what time Jim started
on his break.
<presence from='jim@company-a.com/home' to='john@company-b.com'> <show>chat</show> <status>having a break from work</status> <priority>1</priority> <x xmlns='jabber:x:delay' from='jim@company-a.com/home' stamp='20010611T13:13:04'/> </presence>
Example 2-3 shows us a message element containing a URL attachment. In this case, the element serves to carry the URL attachment; ...
Get Programming Jabber now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.