XEP-0022: Message Events

Abstract:This document defines an XMPP protocol extension used to request and respond to events relating to the delivery, display, and composition of messages. Note: This specification has been obsoleted in favor of XEP-0085 and XEP-0184.
Authors:Jeremie Miller, DJ Adams, Peter Saint-Andre
Copyright:© 1999 - 2014 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status:Obsolete
Type:Historical
Version:1.4
Last Updated:2009-05-27

WARNING: This document has been obsoleted by the XMPP Standards Foundation. Implementation of the protocol described herein is not recommended. Developers desiring similar functionality are advised to implement the protocol that supersedes this one (if any).


Table of Contents


1. Introduction
2. The Events
    2.1. Offline
    2.2. Delivered
    2.3. Displayed
    2.4. Composing
3. Usage
    3.1. Requesting Event Notifications
    3.2. Raising Events
    3.3. The Composing Event
4. Examples
5. Implementation Notes
6. Security Considerations
7. IANA Considerations
8. XMPP Registrar Considerations
9. XML Schema
10. Open Issues

Appendices
    A: Document Information
    B: Author Information
    C: Legal Notices
    D: Relation to XMPP
    E: Discussion Venue
    F: Requirements Conformance
    G: Notes
    H: Revision History


1. Introduction

The 'jabber:x:event' namespace defines extensions used to request and respond to events relating to the delivery, display, and composition of messages.

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.

Note: More modern protocol extensions for this functionality have been defined in Chat State Notifications (XEP-0085) [1] for the composing and offline events and in Message Delivery Receipts (XEP-0184) [2] for the delivered and displayed events; those specifications supersede this one.

2. The Events

There are four message events currently defined in this namespace:

2.1 Offline

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.

2.2 Delivered

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.

2.3 Displayed

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.

2.4 Composing

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.

3. Usage

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.

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.

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 <offline/> tag should be removed from the extension.

3.1 Requesting Event Notifications

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 <offline/>, <delivered/>, <displayed/>, and <composing/>.

An example of a <message/> element with a jabber:x:event extension is shown here.

Example 1. Requesting notification of offline storage and delivery for a message

<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>
  

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.

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.

3.2 Raising Events

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:

Example 2. Raising the offline event

<message
    from='romeo@montague.net'
    to='juliet@capulet.com/balcony'>
  <x xmlns='jabber:x:event'>
    <offline/>
    <id>message22</id>
  </x>
</message>
  

When raising an event, the raiser must send a <message/> element constructed according to the following rules:

3.3 The Composing Event

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.

The cancellation is raised by sending another jabber:x:event; however, in contrast to how the events are usually raised, no <composing/> tag is sent, just an <id/> tag, like this:

Example 3. Romeo begins to compose a reply

<message
    from='romeo@montague.net'
    to='juliet@capulet.com/balcony'>
  <x xmlns='jabber:x:event'>
    <composing/>
    <id>message22</id>
  </x>
</message>
  

Example 4. Romeo pauses to reflect before answering, thus cancelling the composing event

<message
    from='romeo@montague.net'
    to='juliet@capulet.com/balcony'>
  <x xmlns='jabber:x:event'>
    <id>message22</id>
  </x>
</message>
  

The lack of an <composing/> 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.

4. Examples

This section contains a number of examples to illustrate the full flow of messages, event notifications, and event cancellations for a fictional conversation.

Example 5. Juliet sends a message to Romeo and requests all event types

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>
  

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.

Example 6. Receiving the offline event

RECV: <message
          from='romeo@montague.net'
          to='juliet@capulet.com/balcony'>
      <x xmlns='jabber:x:event'>
        <offline/>
        <id>message22</id>
      </x>
    </message>
  

Romeo reconnects and the message is delivered to his Jabber client, which generates a delivered event and sends it to Juliet's client.

Example 7. Juliet receives notification of message delivery

RECV: <message
          from='romeo@montague.net/orchard'
          to='juliet@capulet.com/balcony'>
      <x xmlns='jabber:x:event'>
        <delivered/>
        <id>message22</id>
      </x>
    </message>
  

Romeo's Jabber client displays the message and sends a displayed event to Juliet's client.

Example 8. Juliet receives notification of message display

RECV: <message
          from='romeo@montague.net/orchard'
          to='juliet@capulet.com/balcony'>
      <x xmlns='jabber:x:event'>
        <displayed/>
        <id>message22</id>
      </x>
    </message>
  

Romeo begins composing a reply to Juliet's heartfelt question, and his Jabber client notifies Juliet that he is composing a reply.

Example 9. Juliet receives notification of message composing

RECV: <message
          from='romeo@montague.net/orchard'
          to='juliet@capulet.com/balcony'>
      <x xmlns='jabber:x:event'>
        <composing/>
        <id>message22</id>
      </x>
    </message>
  

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.

Example 10. Juliet receives cancellation of message composing

RECV: <message
          from='romeo@montague.net/orchard'
          to='juliet@capulet.com/balcony'>
      <x xmlns='jabber:x:event'>
        <id>message22</id>
      </x>
    </message>
  

Romeo starts composing again, and his Jabber client sends a notification to Juliet's client.

Example 11. Juliet receives a second notification of message composing

RECV: <message
          from='romeo@montague.net/orchard'
          to='juliet@capulet.com/balcony'>
      <x xmlns='jabber:x:event'>
        <composing/>
        <id>message22</id>
      </x>
    </message>
  

Romeo finally sends his reply, and requests composing events related to it.

Example 12. Romeo replies

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>
  

5. Implementation Notes

Compliant implementations SHOULD observe the following business rules:

  1. 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.
  2. When a client receives a request for events from another entity, it should cache the most recent ID.
  3. 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 <id/> element to the cached ID value.
  4. The CDATA of the <id/> element MUST be the same as the value of the 'id' attribute of the notification request.

6. Security Considerations

There are no security features or concerns related to this proposal.

7. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [3].

8. XMPP Registrar Considerations

No action on the part of the XMPP Registrar [4] is necessary as a result of this document, since 'jabber:x:event' is already a registered protocol namespace.

9. XML Schema

<?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>
    

10. Open Issues

  1. 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).

Appendices


Appendix A: Document Information

Series: XEP
Number: 0022
Publisher: XMPP Standards Foundation
Status: Obsolete
Type: Historical
Version: 1.4
Last Updated: 2009-05-27
Approving Body: XMPP Council
Dependencies: XMPP Core
Supersedes: None
Superseded By: XEP-0085, XEP-0184
Short Name: x-event
Schema: <http://www.xmpp.org/schemas/x-event.xsd>
Source Control: HTML
This document in other formats: XML  PDF


Appendix B: Author Information

Jeremie Miller

Email: jer@jabber.org
JabberID: jer@jabber.org

DJ Adams

Email: dj.adams@pobox.com
JabberID: dj@gnu.mine.nu

Peter Saint-Andre

Email: stpeter@jabber.org
JabberID: stpeter@jabber.org
URI: https://stpeter.im/


Appendix C: Legal Notices

Copyright

This XMPP Extension Protocol is copyright © 1999 - 2014 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <http://xmpp.org/about-xmpp/xsf/xsf-ipr-policy/> or obtained by writing to XMPP Standards Foundation, 1899 Wynkoop Street, Suite 600, Denver, CO 80202 USA).

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.


Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.

Errata can be sent to <editor@xmpp.org>.


Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".


Appendix G: Notes

1. XEP-0085: Chat State Notifications <http://xmpp.org/extensions/xep-0085.html>.

2. XEP-0184: Message Delivery Receipts <http://xmpp.org/extensions/xep-0184.html>.

3. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.

4. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <http://xmpp.org/registrar/>.


Appendix H: Revision History

Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/

Version 1.4 (2009-05-27)

Per a vote of the XMPP Council, changed status to Obsolete. (psa)

Version 1.3 (2004-01-06)

Added XML schema. (psa)

Version 1.2 (2003-02-11)

Attempted to clarify usage and business rules. (psa)

Version 1.1 (2003-01-26)

Added more detailed information and clarified a few points. (psa)

Version 1.0 (2002-05-08)

Changed status to Active. (psa)

Version 0.2 (2002-03-13)

Minor corrections and additions. (dja)

Version 0.1 (2002-03-05)

Initial draft. (dja)

END