Datasheet

14
CHAPTER 1 GettinG to Know XMPP
A <message> stanza is fire and forget; there is no built in reliability, similar to e-mail messages.
Once the message has been sent, the sender has no information on whether it was delivered or when
it was received. In some cases, such as when sending to a non-existent server, the sender may receive
an error stanza alerting them to the problem. Reliable delivery can be achieved by layering acknowl-
edgments into your application’s protocol (see Message Receipts in XEP-0184 for an example of this).
Here are some example
<message> stanzas:
<message from=’bingley@netherfield.lit/drawing_room’
to=’darcy@pemberley.lit’
type=’chat’>
<body>Come, Darcy, I must have you dance.</body>
<thread>4fd61b376fbc4950b9433f031a5595ab</thread>
</message>
<message from=’bennets@chat.meryton.lit/mrs.bennet’
to=’mr.bennet@longbourn.lit/study’
type=’groupchat’>
<body>We have had a most delightful evening, a most excellent ball.</body>
</message>
The first example shows a typical <message> stanza for a private chat, including a thread identier. The
second example is a multi-user chat message that Mrs. Bennet has sent to the bennets@chat.meryton.lit
room, received by Mr. Bennet.
Message Types
Several different types of <message> stanzas exist. These types are indicated with the type attribute,
and this attribute can have the value
chat, error, normal, groupchat, or headline. Sometimes the
messages type is used to inform a user’s client how best to present the message, but some XMPP
extensions, multi-user chat being a prime example, use the
type attribute to disambiguate context.
The
type attribute of a <message> stanza is optional, but it is recommended that applications pro-
vide one. Also, any reply
<message> stanza should mirror the type attribute received. If no type
attribute is specified, the
<message> stanza is interpreted as if it had a type attribute set to normal.
Messages of type
chat are sent in the context of a one-to-one chat conversation. This type is
the most common in IM applications, which are primarily concerned with private, one-to-one
communication.
The
error type is used in reply to a message that generated an error. These are commonly seen in
response to malformed addressing; sending a
<message> stanza to a non-existent domain or user
results in a reply stanza with the
type attribute set to error.
A
<message> stanza with a type of normal has been sent outside the context of a one-to-one chat.
This type is rarely used in practice.
The
groupchat type is used for messages sent from multi-user chats. It is used to disambiguate direct,
private messages from a multi-user chat participant from the broadcast messages that participant
sends to everyone in the room. A private message has the
type attribute set to chat, whereas a mes-
sage sent to everyone in the room contains a
type attribute set to groupchat.
40718c01.indd 14 11/30/09 8:23:50 PM