The examples in this section illustrate a possible instant messaging and presence session. The user is <romeo@example.net>, he has an available resource whose resourcepart is "orchard", and he has the following individuals in his roster:
o <juliet@example.com> (subscription="both" and she has two available resources, "chamber" and "balcony")
o <benvolio@example.net> (subscription="to") o <mercutio@example.org> (subscription="from")
First, the user completes the preconditions (stream establishment, TLS and SASL negotiation, and resource binding) described in
[XMPP-CORE]; those protocol flows are not reproduced here.
Next, the user requests his roster.
Example 1: User requests current roster from server UC: <iq from=’romeo@example.net/orchard’
id=’hf61v3n7’
type=’get’>
<query xmlns=’jabber:iq:roster’/>
</iq>
Example 2: User receives roster from server US: <iq id=’hf61v3n7’
to=’romeo@example.net/orchard’
type=’result’>
<query xmlns=’jabber:iq:roster’>
<item jid=’juliet@example.com’
name=’Juliet’
subscription=’both’>
<group>Friends</group>
</item>
<item jid=’benvolio@example.org’
name=’Benvolio’
subscription=’to’/>
<item jid=’mercutio@example.org’
name=’Mercutio’
subscription=’from’/>
</query>
</iq>
Now the user begins a presence session.
Example 3: User sends initial presence UC: <presence/>
Example 4: User’s server sends presence probes to contacts with subscription="to" and subscription="both" on behalf of the user US: <presence
from=’romeo@example.net’
to=’juliet@example.com’
type=’probe’/>
US: <presence
from=’romeo@example.net’
to=’benvolio@example.org’
type=’probe’/>
Example 5: User’s server sends initial presence to contacts with subscription="from" and subscription="both" on behalf of the user’s available resource, as well as to user
US: <presence
from=’romeo@example.net/orchard’
to=’juliet@example.com’/>
US: <presence
from=’romeo@example.net/orchard’
to=’mercutio@example.org’/>
US: <presence
from=’romeo@example.net/orchard’
to=’romeo@example.net’/>
Example 6: Contacts’ servers reply to presence probe on behalf of all available resources
CS: <presence
from=’juliet@example.com/balcony’
to=’romeo@example.net’
xml:lang=’en’>
<show>away</show>
<status>be right back</status>
<priority>0</priority>
</presence>
CS: <presence
from=’juliet@example.com/chamber’
to=’romeo@example.net’>
<priority>1</priority>
</presence>
CS: <presence
from=’benvolio@example.org/pda’
to=’romeo@example.net’
xml:lang=’en’>
<show>dnd</show>
<status>gallivanting</status>
</presence>
Example 7: Contacts’ servers deliver user’s initial presence to all available resources
CS: <presence
from=’romeo@example.net/orchard’
to=’juliet@example.com’/>
CS: <presence
from=’romeo@example.net/orchard’
to=’juliet@example.com’/>
CS: <presence
from=’romeo@example.net/orchard’
to=’mercutio@example.org’/>
Example 8: User sends directed presence to another user not in his roster
UC: <presence
from=’romeo@example.net/orchard’
to=’nurse@example.com’
xml:lang=’en’>
<show>dnd</show>
<status>courting Juliet</status>
<priority>0</priority>
</presence>
Now the user engages in a chat session with one of his contacts.
Example 9: A threaded conversation CC: <message
from=’juliet@example.com/balcony’
to=’romeo@example.net’
type=’chat’
xml:lang=’en’>
<body>My ears have not yet drunk a hundred words</body>
<thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>
</message>
CC: <message
from=’juliet@example.com/balcony’
to=’romeo@example.net’
type=’chat’
xml:lang=’en’>
<body>Of that tongue’s utterance, yet I know the sound:</body>
<thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>
</message>
CC: <message
from=’juliet@example.com/balcony’
to=’romeo@example.net’
type=’chat’
xml:lang=’en’>
<body>Art thou not Romeo, and a Montague?</body>
<thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>
</message>
UC: <message
from=’romeo@example.net/orchard’
to=’juliet@example.com/balcony’
type=’chat’
xml:lang=’en’>
<body>Neither, fair saint, if either thee dislike.</body>
<thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>
</message>
CC: <message
from=’juliet@example.com/balcony’
to=’romeo@example.net/orchard’
type=’chat’
xml:lang=’en’>
<body>How cam’st thou hither, tell me, and wherefore?</body>
<thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>
</message>
And so on.
The user can also send subsequent presence broadcast.
Example 10: User sends updated available presence for broadcast UC: <presence xml:lang=’en’>
<show>away</show>
<status>I shall return!</status>
<priority>1</priority>
</presence>
Example 11: User’s server broadcasts updated presence to the contacts who have a subscription of type "both" or "from" (but not to the entity to which the user sent directed presence)
US: <presence
from=’romeo@example.net/orchard’
to=’juliet@example.com’
xml:lang=’en’>
<show>away</show>
<status>I shall return!</status>
<priority>1</priority>
</presence>
US: <presence
from=’romeo@example.net/orchard’
to=’mercutio@example.org’
xml:lang=’en’>
<show>away</show>
<status>I shall return!</status>
<priority>1</priority>
</presence>
Example 12: Contacts’ servers deliver updated presence CS: <presence
from=’romeo@example.net/orchard’
to=’juliet@example.com’
xml:lang=’en’>
<show>away</show>
<status>I shall return!</status>
<priority>1</priority>
</presence>
CS: <presence
from=’romeo@example.net/orchard’
to=’juliet@example.com’
xml:lang=’en’>
<show>away</show>
<status>I shall return!</status>
<priority>1</priority>
</presence>
CS: <presence
from=’romeo@example.net/orchard’
to=’mercutio@example.org’
xml:lang=’en’>
<show>away</show>
<status>I shall return!</status>
<priority>1</priority>
</presence>
Example 13: One of the contact’s resources broadcasts unavailable notification
CC: <presence from=’juliet@example.com/chamber’ type=’unavailable’/>
Example 14: Contact’s server sends unavailable notification to user CS: <presence
from=’juliet@example.com/chamber’
to=’romeo@example.net’
type=’unavailable’/>
Now the user ends his presence session.
Example 15: User sends unavailable notification UC: <presence type=’unavailable’ xml:lang=’en’>
<status>gone home</status>
</presence>
Example 16: User’s server broadcasts unavailable notification to contacts as well as to the entity to whom the user sent directed presence
US: <presence
from=’romeo@example.net/orchard’
to=’juliet@example.com’
type=’unavailable’
xml:lang=’en’>
<status>gone home</status>
</presence>
US: <presence
from=’romeo@example.net/orchard’
to=’mercutio@example.org’
type=’unavailable’
xml:lang=’en’>
<status>gone home</status>
</presence>
US: <presence
from=’romeo@example.net/orchard’
to=’nurse@example.com’
type=’unavailable’
xml:lang=’en’>
<status>gone home</status>
</presence>
Finally the user closes his stream and the server responds in kind.
Example 17: User closes stream UC: </stream:stream>
Example 18: User’s server closes stream US: </stream:stream>
THE END