Work with Enhanced Presence Using Unified Communications AJAX Service API
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
The AJAX Service API supports publication and subscription of enhanced presence.
To publish the presence information, an AJAX API client sends, through the command channel, a request containing relevant presence category instances. A request in AJAX API is embodied in a <cwaRequests> element and contains one or more <cwaCateogry> elements to hold specified presence data. The following example shows a request to publish a presence note.
<cwaRequests sid="123" xmlns = "http://schemas.microsoft.com/2006/09/rtc/cwa"> <publishSelfPresence rid="2"> <cwaCategory name="note" instanceMask="0" expires="-1"> <note xmlns="http://schemas.microsoft.com/2006/09/sip/note"> <body type="personal">This is a personal note</body> </note> </cwaCategory> </publishSelfPresence> </cwaRequests>
In the example above, the <publishSelfPresence> element describes the command of the request. This and the other two elements, <cwaRequest> and <cwaCateogry>, are defined by the AJAX API. The <note> element, however, is defined by the Enhanced Presence Schemas described in this document.
To subscribe to the presence information of a specified user, an AJAX API client registers for event notifications to receive and handle the userPresence events from the event channel. The userPresence event is described by an <userPresence> element, which is enveloped within a <cwaEvents> element. The event element contains a user element (<user>) and one or more <cwaCategory> elements. Each <cwaCategory> element in turn contains one or more enhanced presence elements describing the user's presence information, including the user state (<state>), note (<note>), contact information (<contactCard>), and others. Here, the <cwaEvents>, <userPresence>, and <user> elements are all defined by the AJAX Service API. As with the case of the presence publication discussed above, the child elements of a <cwaCategory> element are of the Enhanced Presence Schemas elements. The following event example returns the presence state, note, and a contact card of a user (sip:email@example.com).
<cwaEvents> <userPresence eid="10"> <user uri="sip:firstname.lastname@example.org" sourceNetwork="sameEnterprise"> <cwaCategory name="state" instance="0"> <state xmlns=".../sip/state" xmlns:xsi=".../XMLSchema-instance" xsi:type="aggregateState"> <availability>18000</availability> <activity token="Offline" /> </state> </cwaCategory> <cwaCategory name="note" instance="0"> <note xmlns=".../sip/note"> <body type="personal" /> </note> </cwaCategory> <cwaCategory name="contactCard" instance="0"> <contactCard xmlns=".../sip/contactcard"> <identity> <name> <displayName>Jay A.</displayName> </name> </identity> </contactCard> </cwaCategory> </user> </userPresence> </cwaEvents>
To receive the self presence information, an AJAX API client needs to handle the <selfPresence> events. The programming pattern is similar to handling the <userPresence> events.
Unified Communications AJAX Service API also supports publishing and receiving custom presence information. For more information, see the Unified Communications AJAX 2007 SDK documentation.