Datasheet

12
CHAPTER 1 GettinG to Know XMPP
The first two stanzas set a user’s presence status to online or ofine, respectively. These are also
typically the first and last presence stanzas sent during an XMPP session.
The next two examples both show extra presence information in the form of
<show>, <status>,
and
<priority> children.
The
<show> element is used to communicate the nature of the user’s availability. The element is
named “show” because it requests that the recipient’s client use this information to update a visual
indicator of the sender’s presence. Only one
<show> child is allowed in a <presence> stanza, and
this element may only contain the following possible values:
away, chat, dnd, and xa. These values
communicate that a user is away, is interested in chatting, does not wish to be disturbed, or is away
for an extended period.
A
<status> element is a human-readable string that the user can set to any value in order to com-
municate presence information. This string is generally displayed next to the contacts name in the
recipient’s chat client.
Each connected resource of a user has a priority between –128 and 127. This priority is set to zero
by default, but can be manipulated by including a
<priority> element in <presence> stanzas.
Users with multiple simultaneous connections may use this to indicate which resource should receive
chat messages addressed to their bare JID. The server will deliver such messages to the resource with
the highest priority. A negative priority has a special meaning; resources with a negative priority will
never have messages delivered to them that were addressed to the bare JID. Negative priorities are
extremely useful for automated applications that run on the same JID as a human is using for regu-
lar chat.
Extending Presence Stanzas
It is tempting for developers to want to extend <presence> stanzas to include more detailed infor-
mation such as the song the user is currently listening to or the person’s mood. Because
<presence>
stanzas are broadcast to all contacts (even those that may not have an interest in the information)
and constitute a large share of the network traffic in the XMPP network, this practice is discouraged.
These kinds of extensions are handled by protocols that more tightly focus delivery of this extra
information.
Presence Subscriptions
The user’s server automatically broadcasts presence information to contacts that have a presence
subscription to the user. Similarly, users receive presence updates from all contacts for which they
have a presence subscription. Presence subscriptions are established and controlled by use of
<pres-
ence>
stanzas.
Unlike some social network and IM systems, presence subscriptions in XMPP are directional. If
Elizabeth has a subscription to Mr. Darcys presence information, this does not imply that Mr.
Darcy has a subscription to Elizabeth. If a bidirectional subscription is desired, a subscription must
be separately established in both directions. Bidirectional subscriptions are often the norm for
human communicators, but many services (and even some users) are interested in only one of the
directions.
40718c01.indd 12 11/30/09 8:23:49 PM