1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-25 10:42:19 -05:00
xeps/xep-0022.xml

323 lines
17 KiB
XML
Raw Normal View History

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
<!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
<title>Message Events</title>
<abstract>This document defines an XMPP protocol extension used to request and respond to events relating to the delivery, display, and composition of messages.</abstract>
&LEGALNOTICE;
<number>0022</number>
<status>Active</status>
<type>Historical</type>
<sig>Standards</sig>
<dependencies>
<spec>XMPP Core</spec>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>x-event</shortname>
<schemaloc>
<url>http://www.xmpp.org/schemas/x-event.xsd</url>
</schemaloc>
&jer;
<author>
<firstname>DJ</firstname>
<surname>Adams</surname>
<email>dj.adams@pobox.com</email>
<jid>dj@gnu.mine.nu</jid>
</author>
&stpeter;
<revision>
<version>1.3</version>
<date>2004-01-06</date>
<initials>psa</initials>
<remark>Added XML schema.</remark>
</revision>
<revision>
<version>1.2</version>
<date>2003-02-11</date>
<initials>psa</initials>
<remark>Attempted to clarify usage and business rules.</remark>
</revision>
<revision>
<version>1.1</version>
<date>2003-01-26</date>
<initials>psa</initials>
<remark>Added more detailed information and clarified a few points.</remark>
</revision>
<revision>
<version>1.0</version>
<date>2002-05-08</date>
<initials>psa</initials>
<remark>Changed status to Active.</remark>
</revision>
<revision>
<version>0.2</version>
<date>2002-03-13</date>
<initials>dja</initials>
<remark>Minor corrections and additions.</remark>
</revision>
<revision>
<version>0.1</version>
<date>2002-03-05</date>
<initials>dja</initials>
<remark>Initial draft.</remark>
</revision>
</header>
<section1 topic='Introduction'>
<p>The 'jabber:x:event' namespace defines extensions used to request and respond to events relating to the delivery, display, and composition of messages.</p>
<p>By attaching a jabber:x:event extension to a &MESSAGE; element, the sender can track stages in the delivery of that message to its recipient.</p>
<p><em>Note: A more modern protocol extension for this functionality has been been defined in &xep0085;.</em></p>
</section1>
<section1 topic='The Events'>
<p>There are four message events currently defined in this namespace:</p>
<section2 topic='Offline'>
<p>Indicates that the message has been stored offline by the intended recipient's server. This event is triggered only if the intended recipient's server supports offline storage, has that support enabled, and the recipient is offline when the server receives the message for delivery.</p>
</section2>
<section2 topic='Delivered'>
<p>Indicates that the message has been delivered to the recipient. This signifies that the message has reached the recipient's Jabber client, but does not necessarily mean that the message has been displayed. This event is to be raised by the Jabber client.</p>
</section2>
<section2 topic='Displayed'>
<p>Once the message has been received by the recipient's Jabber client, it may be displayed to the user. This event indicates that the message has been displayed, and is to be raised by the Jabber client. Even if a message is displayed multiple times, this event should be raised only once.</p>
</section2>
<section2 topic='Composing'>
<p>In threaded chat conversations, this indicates that the recipient is composing a reply to a message. The event is to be raised by the recipient's Jabber client. A Jabber client is allowed to raise this event multiple times in response to the same request, providing the original event is cancelled first.</p>
</section2>
</section1>
<section1 topic='Usage'>
<p>Extensions qualified by the jabber:x:event namespace may be used only in the context of &MESSAGE; elements. That is, event information should be requested, and given in response, in relation to &MESSAGE; elements only, and not &PRESENCE; or &IQ; elements.</p>
<p>Event information should only be sent in response to a request for that information. Unsolicited event information is illegal. In addition, a client should not request message event information from a correspondent if it is known (for example through the results of a previous browse request) that the correspondent does not support message events.</p>
<p>Any request for the offline event in a message that has been stored offline must be removed by the server before the message is forwarded to the Jabber client. This means that any &lt;offline/&gt; tag should be removed from the extension.</p>
<section2 topic='Requesting Event Notifications'>
<p>Event notifications are requested by attaching an extension qualified by the jabber:x:event namespace to a &MESSAGE; element. A tag representing each event type requested for that message should be placed within the extension. Only one jabber:x:event extension may be attached to a &MESSAGE; element, but multiple event types may be requested within that one extension. The tags representing each of the event types are &lt;offline/&gt;, &lt;delivered/&gt;, &lt;displayed/&gt;, and &lt;composing/&gt;.</p>
<p>An example of a &MESSAGE; element with a jabber:x:event extension is shown here.</p>
<example caption='Requesting notification of offline storage and delivery for a message'><![CDATA[
<message to='romeo@montague.net' id='message22'>
<body>Art thou not Romeo, and a Montague?</body>
<x xmlns='jabber:x:event'>
<offline/>
<delivered/>
<composing/>
</x>
</message>
]]></example>
<p>Here we see the sender wants to be notified if the message is stored offline (by the server), notified when the message is delivered (to the client), and notified if the recipient begins replying to the message. In this case, the sender will potentially receive three events based on this request. The first if the recipient is offline and the message is stored on the server, the second when the recipient becomes available and the message is delivered, and the third if the recipient begins composing a reply to the message.</p>
<p>Note that the &MESSAGE; element requesting event notification contains an 'id' attribute. While these attributes are optional in the Jabber protocol, messages that contain event notification requests MUST contain an 'id' attribute so that raised events may be matched up with their original requests.</p>
</section2>
<section2 topic='Raising Events'>
<p>If the message is stored by the server, the server must raise the requested event (offline) by sending a message to the sender as shown in this example:</p>
<example caption='Raising the offline event'><![CDATA[
<message
from='romeo@montague.net'
to='juliet@capulet.com/balcony'>
<x xmlns='jabber:x:event'>
<offline/>
<id>message22</id>
</x>
</message>
]]></example>
<p>When raising an event, the raiser must send a &MESSAGE; element constructed according to the following rules:</p>
<ul>
<li>The element must contain only a jabber:x:event extension. Standard message elements such as &lt;subject/&gt;, &lt;body/&gt;, MUST NOT be included.</li>
<li>The extension must contain one tag representing the event being raised. For example, if the offline event is being raised, an &lt;offline/> tag must be included. (The events are temporally exclusive, thus only one event tag should ever be included.)</li>
<li>The extension must also contain an &lt;id/&gt; tag. The contents of this tag MUST be the value of the 'id' <em>attribute</em> of the original message to which this event notification pertains. (If no 'id' attribute was included in the original message, then the &lt;id/&gt; tag must still be included with no CDATA.)</li>
<li>The message's from attribute should be set to the recipient of the original message for which the event is being raised. (This is an issue more relevant for the server, in responding to the offline event, because clients should rely on the server to stamp the elements that they send out with a from attribute.)</li>
<li>The link between the original message for which the event is being raised, and the message containing that raised event, is the &lt;id/&gt; tag in the jabber:x:event extension of the message containing that raised event, that points to the id attribute of the original message.</li>
</ul>
</section2>
<section2 topic='The Composing Event'>
<p>The composing event is slightly different from the other events in that it can be raised and cancelled multiple times. This is to allow the reflection of what actually is happening when a user replies to a message; he may start composing a reply, which would trigger the composing event, get halfway through, and stop (by some definition of "stop", which may be implementation-specific). At this stage the event is no longer valid, or at least doesn't make much sense. So the client may send a cancellation for the composing event just raised.</p>
<p>The cancellation is raised by sending another jabber:x:event; however, in contrast to how the events are usually raised, no &lt;composing/&gt; tag is sent, just an &lt;id/&gt; tag, like this:</p>
<example caption='Romeo begins to compose a reply'><![CDATA[
<message
from='romeo@montague.net'
to='juliet@capulet.com/balcony'>
<x xmlns='jabber:x:event'>
<composing/>
<id>message22</id>
</x>
</message>
]]></example>
<example caption='Romeo pauses to reflect before answering, thus cancelling the composing event'><![CDATA[
<message
from='romeo@montague.net'
to='juliet@capulet.com/balcony'>
<x xmlns='jabber:x:event'>
<id>message22</id>
</x>
</message>
]]></example>
<p>The lack of an &lt;composing/&gt; tag (and any other event tag) signifies that the composing event, indicated previously by the id value, has been cancelled. In this example, the composing event being cancelled is that event that was previously raised with the id of message22. After cancelling a composing event, a new one may be raised, following the same rules as before, when the typing of the reply is resumed.</p>
</section2>
</section1>
<section1 topic='Examples'>
<p>This section contains a number of examples to illustrate the full flow of messages, event notifications, and event cancellations for a fictional conversation.</p>
<example caption='Juliet sends a message to Romeo and requests all event types'><![CDATA[
SEND: <message to='romeo@montague.net' id='message22'>
<body>Art thou not Romeo, and a Montague?</body>
<x xmlns='jabber:x:event'>
<offline/>
<delivered/>
<displayed/>
<composing/>
</x>
</message>
]]></example>
<p>Romeo temporarily loses his wireless connection in the Capulet's orchard and therefore his message is stored offline by the montague.net server, which generates the offline event and sends that notification to Juliet.</p>
<example caption='Receiving the offline event'><![CDATA[
RECV: <message
from='romeo@montague.net'
to='juliet@capulet.com/balcony'>
<x xmlns='jabber:x:event'>
<offline/>
<id>message22</id>
</x>
</message>
]]></example>
<p>Romeo reconnects and the message is delivered to his Jabber client, which generates a delivered event and sends it to Juliet's client.</p>
<example caption='Juliet receives notification of message delivery'><![CDATA[
RECV: <message
from='romeo@montague.net/orchard'
to='juliet@capulet.com/balcony'>
<x xmlns='jabber:x:event'>
<delivered/>
<id>message22</id>
</x>
</message>
]]></example>
<p>Romeo's Jabber client displays the message and sends a displayed event to Juliet's client.</p>
<example caption='Juliet receives notification of message display'><![CDATA[
RECV: <message
from='romeo@montague.net/orchard'
to='juliet@capulet.com/balcony'>
<x xmlns='jabber:x:event'>
<displayed/>
<id>message22</id>
</x>
</message>
]]></example>
<p>Romeo begins composing a reply to Juliet's heartfelt question, and his Jabber client notifies Juliet that he is composing a reply.</p>
<example caption='Juliet receives notification of message composing'><![CDATA[
RECV: <message
from='romeo@montague.net/orchard'
to='juliet@capulet.com/balcony'>
<x xmlns='jabber:x:event'>
<composing/>
<id>message22</id>
</x>
</message>
]]></example>
<p>Romeo realizes his reply is too rash and pauses to choose the right words; his Jabber client senses the delay and cancels the previous composing event.</p>
<example caption='Juliet receives cancellation of message composing'><![CDATA[
RECV: <message
from='romeo@montague.net/orchard'
to='juliet@capulet.com/balcony'>
<x xmlns='jabber:x:event'>
<id>message22</id>
</x>
</message>
]]></example>
<p>Romeo starts composing again, and his Jabber client sends a notification to Juliet's client.</p>
<example caption='Juliet receives a second notification of message composing'><![CDATA[
RECV: <message
from='romeo@montague.net/orchard'
to='juliet@capulet.com/balcony'>
<x xmlns='jabber:x:event'>
<composing/>
<id>message22</id>
</x>
</message>
]]></example>
<p>Romeo finally sends his reply, and requests composing events related to it.</p>
<example caption='Romeo replies'><![CDATA[
SEND: <message to='juliet@capulet.com' id='GabberMessage43'>
<body>Neither, fair saint, if either thee dislike.</body>
<x xmlns='jabber:x:event'>
<composing/>
</x>
</message>
]]></example>
</section1>
<section1 topic='Implementation Notes'>
<p>Compliant implementations SHOULD observe the following business rules:</p>
<ol>
<li>Every outgoing message sent from a compliant client should contain a request for event notifications (if such notifications are desired). The request for notifications cannot be sent just once in a conversation, since it applies to every message sent.</li>
<li>When a client receives a request for events from another entity, it should cache the most recent ID.</li>
<li>When a user begins replying to a message received from a contact, the user's client should check to see whether events have been requested by the contact for that message and set the CDATA of the &lt;id/&gt; element to the cached ID value.</li>
<li>The CDATA of the &lt;id/&gt; element MUST be the same as the value of the 'id' attribute of the notification request.</li>
</ol>
</section1>
<section1 topic='Security Considerations'>
<p>There are no security features or concerns related to this proposal.</p>
</section1>
<section1 topic='IANA Considerations'>
<p>This document requires no interaction with &IANA;.</p>
</section1>
<section1 topic='XMPP Registrar Considerations'>
<p>No action on the part of the &REGISTRAR; is necessary as a result of this document, since 'jabber:x:event' is already a registered protocol namespace.</p>
</section1>
<section1 topic='XML Schema'>
<code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
xmlns:xs='http://www.w3.org/2001/XMLSchema'
targetNamespace='jabber:x:event'
xmlns='jabber:x:event'
elementFormDefault='qualified'>
<xs:annotation>
<xs:documentation>
The protocol documented by this schema is defined in
XEP-0022: http://www.xmpp.org/extensions/xep-0022.html
</xs:documentation>
</xs:annotation>
<xs:element name='x'>
<xs:complexType>
<xs:sequence>
<xs:element name='offline' minOccurs='0' type='empty'/>
<xs:element name='delivered' minOccurs='0' type='empty'/>
<xs:element name='displayed' minOccurs='0' type='empty'/>
<xs:element name='composing' minOccurs='0' type='empty'/>
<xs:element name='id' minOccurs='0' type='xs:NMTOKEN'/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name='empty'>
<xs:restriction base='xs:string'>
<xs:enumeration value=''/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
]]></code>
</section1>
<section1 topic='Open Issues'>
<ol>
<li>In a Standards Track specification addressing event functionality, it would be desirable to have more cancellation methods for composing events than those defined in this Informational document. For instance, is someone still composing if they become unavailable? This example points to the fact that cancellation of a composing event can either be explicit (the default or desired scenario) or implicit (e.g., through a change in the availability state of a client or the existence of the session associated with the message composition).</li>
</ol>
</section1>
</xep>