Datasheet
XMPP Stanzas
11
data. In all these cases, the client uses the id attribute of the reply stanza to identify which request
stanza it is associated with. In cases where many stanzas of the same type are sent in a short time
frame, this capability is essential because the replies may be delivered out of order.
Presence Stanzas
The <presence> stanza controls and reports the availability of an entity. This availability can range
from simple online and offline to the more complex away and do not disturb. In addition,
<presence>
stanzas are used to establish and terminate presence subscriptions to other entities.
In traditional instant messaging systems, presence notifications are the main source of traffic. To
enable instant communication, it is necessary to know when the other party is available to communi-
cate. When you send an e-mail, you have no idea if the recipient is currently checking and responding
to e-mail, but with instant messages and presence notifications, you know before the message is sent
if the recipient is around.
For applications in other domains, presence notifications can be used to signal similar kinds of infor-
mation. For example, some developers have written bots that set their presence to do not disturb
when they are too busy to accept more work. The basic online and offline states can let applications
know whether a service is currently functioning or down for maintenance.
Normal Presence Stanzas
A normal <presence> stanza contains no type attribute or a type attribute that has the value
unavailable or error. These stanzas set or indicate an entity’s presence or availability for
communication.
There is no
available value for the type attribute because this is indicated instead by the lack of a
type attribute.
Users manipulate their own presence status by sending
<presence> stanzas without a to attribute,
addressing the server directly. You’ve seen two short examples of this already, and these are included
along with some longer examples here:
<presence/>
<presence type=’unavailable’/>
<presence>
<show>away</show>
<status>at the ball</status>
</presence>
<presence>
<status>touring the countryside</status>
<priority>10</priority>
</presence>
<presence>
<priority>10</priority>
</presence>
40718c01.indd 11 11/30/09 8:23:49 PM