XEP-0168: Resource Application Priority

This document defines an XMPP protocol extension to indicate the presence priority of XMPP resources for applications other than messaging.


WARNING: This Standards-Track document is Experimental. Publication as an XMPP Extension Protocol does not imply approval of this proposal by the XMPP Standards Foundation. Implementation of the protocol described herein is encouraged in exploratory implementations, but production systems should not deploy implementations of this protocol until it advances to a status of Draft.


Document Information

Series: XEP
Number: 0168
Publisher: XMPP Standards Foundation
Status: Experimental
Type: Standards Track
Version: 0.4
Last Updated: 2007-06-06
Approving Body: XMPP Council
Dependencies: XMPP Core, XMPP IM, XEP-0030
Supersedes: None
Superseded By: None
Short Name: TO BE ASSIGNED
Wiki Page: <http://wiki.jabber.org/index.php/Resource Application Priority (XEP-0168)>

Author Information

Peter Saint-Andre

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

Joe Hildebrand

Email: jhildebrand@jabber.com
JabberID: hildjj@jabber.org

Legal Notices

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which may be found at <http://www.xmpp.org/extensions/ipr-policy.shtml> or obtained by writing to XSF, P.O. Box 1641, Denver, CO 80201 USA).

Copyright

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

Permissions

This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution License (<http://creativecommons.org/licenses/by/2.5/>).

Discussion Venue

The preferred venue for discussion of this document is the Standards discussion list: <http://mail.jabber.org/mailman/listinfo/standards>.

Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) 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.

Conformance Terms

The following 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".


Table of Contents


1. Introduction
2. Application Priority
3. Flagging the Primary Resource
4. RAP-Based Message Routing
5. Determining Support
6. Security Considerations
7. IANA Considerations
8. XMPP Registrar Considerations
    8.1. Protocol Namespaces
9. XML Schemas
    9.1. RAP
    9.2. RAP Routing
Notes
Revision History


1. Introduction

Within the Extensible Messaging and Presence Protocol (XMPP; see RFC 3920 [1]), presence indicates availability for communication -- specifically, communication via XMPP messaging in the "jabber:client" namespace (usually in the form of "instant messaging" or IM as described in RFC 3921 [2]). However, a wide variety of entities might provide XMPP presence, including entities that are not primarily focused on IM (e.g., phones) or even entities that do not support XMPP messaging at all.

Consider a scenario in which a contact wants to initiate a voice chat (e.g., via Jingle [3]) with a user who has the following three XMPP resources:

Table 1: Application Presence

Resource Messaging Priority Voice Chat Priority
desktop 10 5
pda 5 -1
mobile -1 10

If the contact chooses the resource with which it initiates a voice chat based on the user's default XMPP presence priority (i.e., priority for XMPP messaging), the resulting behavior could be misleading (i.e., initiating the voice chat with the "desktop" resource rather than the "mobile" resource).

What is needed is a way for the user's clients to indicate that the application priority for the three resources is different from the standard XMPP messaging priority. Such information can also be used by an XMPP server to route XMPP <message/> stanzas directed to a user's bare JID (<node@domain.tld>). This document defines such a mechanism via an optional XMPP presence extension.

In addition, this document also defines a way for an XMPP server to flag which resource it considers to be primary for any given application type, if it has information -- such as communication preferences -- that can help determine the primary resource.

2. Application Priority

Consider the three resources ("desktop", "pda", and "mobile") mentioned above. The presence stanzas received by a contact for those three resources would be as follows (see Protocol Namespaces regarding issuance of one or more permanent namespaces):

Example 1. Contact receives presence from user

<presence from='juliet@capulet.com/desktop' to='romeo@montague.net/home'>
  <priority>10</priority>
  <rap xmlns='http://www.xmpp.org/extensions/xep-0168.html#ns' 
       ns='http://www.xmpp.org/extensions/xep-0167#ns' 
       num='5'/>
</presence>

<presence from='juliet@capulet.com/pda' to='romeo@montague.net/home'>
  <priority>5</priority>
  <rap xmlns='http://www.xmpp.org/extensions/xep-0168.html#ns' 
       ns='http://www.xmpp.org/extensions/xep-0167#ns' 
       num='-1'/>
</presence>

<presence from='juliet@capulet.com/mobile' to='romeo@montague.net/home'>
  <priority>-1</priority>
  <rap xmlns='http://www.xmpp.org/extensions/xep-0168.html#ns' 
       ns='http://www.xmpp.org/extensions/xep-0167#ns' 
       num='10'/>
</presence>
  

(Note: This protocol uses a 'num' attribute rather than a 'priority' attribute to reduce confusion with XMPP presence.)

The following business rules apply to resource application presence provided by the client:

  1. A client SHOULD NOT specify resource application presence if the priority for that application is the same as the resource's XMPP messaging priority.

  2. A client MUST NOT generate a <rap/> element that has a 'ns' attribute whose value is "jabber:client" or that has no 'ns' attribute (since the default 'ns' is "jabber:client").

3. Flagging the Primary Resource

The user's server may have special information that enables it to flag a resource as primary for a given application type. For instance, the server may include a communication policy service that enables the user to define (outside the context of any presence priorities) that she would prefer to be called at her desktop computer only between the hours of 9:00 AM and 5:00 PM local time, prefer to be called on her mobile phone at all other times, and so on.

To flag the primary resource related to a specific application type, the server shall add a <primary/> child to the relevant RAP element. Here is an example:

Example 2. Primary resource flag

<presence from='juliet@capulet.com/mobile'>
  <priority>-1</priority>
  <rap xmlns='http://www.xmpp.org/extensions/xep-0168.html#ns' 
       ns='http://www.xmpp.org/extensions/xep-0167#ns' 
       num='10'>
    <primary/>
  </rap>
</presence>
  

The following business rules apply to resource flagging by the server:

  1. A server MAY add the primary resource flag to the presence broadcasts generated by the resource it determines is "most available" for a given application type.

  2. Because the default 'ns' is "jabber:client", to flag the primary resource for XMPP messaging the server SHOULD NOT include a 'ns' attribute, SHOULD NOT include a 'num' attribute, and MUST include a <primary/> child.

  3. An available resource that has specified a negative priority for an application type MUST NOT be flagged as the primary resource for that application type.

  4. A client SHOULD NOT include the primary resource flag in presence stanzas that it generates; however, if a client includes the primary resource flag in a presence stanza, the server SHOULD remove or overwrite the flag.

  5. In response to a presence probe, a server SHOULD send presence from the primary resource first (this enables the receiving client to skip any local most-available algorithms it might implement).

  6. If the primary resource changes for a given application type, a server MUST push presence (including the primary resource flag) for the new primary resource. If the change in primary resource occurs because of a presence broadcast from the current primary resource, the server MUST push presence from the current primary resource (without the primary resource flag) before pushing presence from the new primary resource (including the primary resource flag).

4. RAP-Based Message Routing

A server MAY use the RAP data provided by clients in order to route incoming <message/> stanzas directed to the bare JID (<node@domain.tld>) of a registered account. In order to enable such routing, the sender MUST include an empty <route/> element qualified by the 'http://www.xmpp.org/extensions/xep-0168.html#ns-raproute' namespace (see Protocol Namespaces regarding issuance of one or more permanent namespaces) including an 'ns' attribute corresponding to the desired application.

For example, consider a Stanza Session Negotiation [4] request sent from one user (Romeo) to another (Juliet), where the users do not share presence:

Example 3. User requests session

<message type='headline'
         from='romeo@montague.net/orchard'
         to='juliet@capulet.com'>
  <route xmlns='http://www.xmpp.org/extensions/xep-0168.html#ns-raproute'
         ns='http://www.xmpp.org/extensions/xep-0167#ns'/>
  <thread>ffd7076498744578d10edabfe7f4a866</thread>
  <feature xmlns='http://jabber.org/protocol/feature-neg'>
    <x xmlns='jabber:x:data' type='form'>
      <title>Open chat with Romeo?</title>
      <field var='FORM_TYPE' type='hidden'>
        <value>urn:xmpp:ssn</value>
      </field>
      <field label='Accept this session?' type='boolean' var='accept'>
        <value>true</value>
        <required/>
      </field>
      ...
  </feature>
</message>
    

If Juliet's server supports RAP routing, it would then deliver the message to whichever of Juliet's resources has the highest priority for the "http://www.xmpp.org/extensions/xep-0167#ns" application type.

5. Determining Support

In order to discover whether a server or other entity supports this protocol, an entity MUST use Service Discovery [5].

Example 4. Entity queries a server regarding protocol support

<iq type='get'
    from='juliet@capulet.com/balcony'
    to='capulet.com'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
  

If the queried entity supports the functionality specified herein, it MUST return the following features (see Protocol Namespaces regarding issuance of one or more permanent namespaces):

Example 5. Server communicates protocol support for RAP

<iq type='result'
    from='capulet.com'
    to='juliet@capulet.com/balcony'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
    <feature var='http://www.xmpp.org/extensions/xep-0168.html#ns'/>
    <feature var='http://www.xmpp.org/extensions/xep-0168.html#ns-route'/>
    ...
  </query>
</iq>
  

6. Security Considerations

Neither client publishing of resource application priority nor server flagging of the primary resource introduces any known security vulnerabilities or compromises of user privacy.

7. IANA Considerations

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

8. XMPP Registrar Considerations

8.1 Protocol Namespaces

Until this specification advances to a status of Draft, its associated namespaces shall be:

Upon advancement of this specification, the XMPP Registrar [7] shall issue permanent namespaces in accordance with the process defined in Section 4 of XMPP Registrar Function [8].

9. XML Schemas

9.1 RAP

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://www.xmpp.org/extensions/xep-0168.html#ns'
    xmlns='http://www.xmpp.org/extensions/xep-0168.html#ns'
    elementFormDefault='qualified'>

  <xs:element name='rap'>
    <xs:complexType>
      <xs:sequence>
        <xs:element name='primary' type='empty' minOccurs='0'/>
      </xs:sequence>
      <xs:attribute name='ns' type='xs:string' default='jabber:client'/>
      <xs:attribute name='num' type='xs:byte'/>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name='empty'>
    <xs:restriction base='xs:string'>
      <xs:enumeration value=''/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

    

9.2 RAP Routing

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://www.xmpp.org/extensions/xep-0168.html#ns-route'
    xmlns='http://www.xmpp.org/extensions/xep-0168.html#ns-route'
    elementFormDefault='qualified'>

  <xs:element name='route'>
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base='empty'>
          <xs:attribute name='ns' type='xs:string' default='jabber:client'/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name='empty'>
    <xs:restriction base='xs:string'>
      <xs:enumeration value=''/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

    

Notes

1. RFC 3920: Extensible Messaging and Presence Protocol (XMPP): Core <http://tools.ietf.org/html/rfc3920>.

2. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/rfc3921>.

3. XEP-0166: Jingle <http://www.xmpp.org/extensions/xep-0166.html>.

4. XEP-0155: Stanza Session Negotiation <http://www.xmpp.org/extensions/xep-0155.html>.

5. XEP-0030: Service Discovery <http://www.xmpp.org/extensions/xep-0030.html>.

6. 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/>.

7. 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://www.xmpp.org/registrar/>.

8. XEP-0053: XMPP Registrar Function <http://www.xmpp.org/extensions/xep-0053.html>.


Revision History

Version 0.4 (2007-06-06)

Added section on RAP-based routing of messages sent to bare JIDs; removed RAP request protocol; changed app attribute to ns attribute; removed the application types registry since it is unnecessary if the ns attribute specifies the XML namespace of the data most closely associated with the application type; updated namespaces to conform to XMPP Registrar processes.

(psa)

Version 0.3 (2006-09-17)

Changed im application type to messaging; added jingle-video.

(psa)

Version 0.2 (2005-12-19)

Clarified structure of, and added schema for, RAP request namespace.

(psa)

Version 0.1 (2005-12-15)

Initial published version.

(psa)

Version 0.0.6 (2005-11-29)

Document cleanup.

(psa)

Version 0.0.5 (2005-11-17)

Added support for RAP requests via IQ.

(psa)

Version 0.0.4 (2005-10-27)

Defined registry of application types; clarified business rules; corrected schema.

(psa/jjh)

Version 0.0.3 (2005-10-24)

Broadened previous resource flagging proposal to include priority for applications other than messaging.

(psa/jjh)

Version 0.0.2 (2005-09-26)

Added more business rules and examples; defined service discovery guidelines.

(psa/jjh)

Version 0.0.1 (2005-09-23)

First draft.

(psa/jjh)

END