Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Custom Presence in the Windows Live Messenger Library


Published on

Overview deck of the custom presence features in the Windows Live Messenger Library

Published in: Business, Technology
  • Be the first to comment

Custom Presence in the Windows Live Messenger Library

  1. 1. Windows Live Messenger Library Custom Presence
  2. 2. <ul><li>Custom Presence allows your web application to set custom presence properties on Messenger users </li></ul><ul><li>Uses: </li></ul><ul><ul><li>Detect when two users are both signed into your custom Messenger application </li></ul></ul><ul><ul><li>Enables sharing of rich presence information between users of your web application </li></ul></ul><ul><li>This allows you to ‘light up’ extra features between multiple users who are signed into your site </li></ul>
  3. 3. <ul><li>Create a presence extension object </li></ul><ul><ul><li>This object must support the get_name() method </li></ul></ul><ul><ul><li>Other methods/data are up to you </li></ul></ul><ul><li>Create a PresenceExtensionFactory object with two methods: </li></ul><ul><ul><li>serialize(property): output a string representation of the presence extension object </li></ul></ul><ul><ul><li>deserialize(name, content): recreate the presence extension from the string representation </li></ul></ul><ul><li>Set your PresenceExtensionFactory as the active presence factory </li></ul><ul><li>Add the presence extension to users’ presence </li></ul>
  4. 4. <ul><li>This Presence Extension stores simple name/value pairs – they can be fancier </li></ul><ul><li>var EXTENSION_NAME = ‘ExtNm’ // 6 chars or less </li></ul><ul><li>function MyPresenceExtension(name, content) { </li></ul><ul><li>this .name = name; </li></ul><ul><li>this .content = content; </li></ul><ul><li>} </li></ul><ul><li>MyPresenceExtension.prototype.get_name = function () { </li></ul><ul><li>return this .name; </li></ul><ul><li>} </li></ul><ul><li>MyPresenceExtension.prototype.get_content = function () { </li></ul><ul><li>return this .content; </li></ul><ul><li>} </li></ul>
  5. 5. <ul><li>This object serializes and deserializes your custom presence extension </li></ul>MyPresenceFactory = function () {} MyPresenceFactory.prototype.serialize = function (prop) { return prop.get_content(); } MyPresenceFactory.prototype.deserialize = function (name, content) { return new MyPresenceExtension(name, content); }
  6. 6. <ul><li>Add your presence factory to the user object </li></ul><ul><li>user.set_presenceFactory( new MyPresenceFactory()); </li></ul><ul><li>Add your presence extension to the signed-in user </li></ul><ul><li>endpointColl = user.get_endpoints(); </li></ul><ul><li>endpointPresence = endpointColl.get_item(0).get_presence(); </li></ul><ul><li>extensionColl = endpointPresence.get_extensions(); </li></ul><ul><li>extensionColl.add( new MyPresenceExtension(EXTENSION_NAME, 'Content' )); </li></ul>
  7. 7. <ul><li>For each contact, check their endpoints for the presence extension </li></ul><ul><li>endpointEnum = address.get_endpoints().getEnumerator(); </li></ul><ul><li>while (endpointEnum.moveNext()) { </li></ul><ul><li>endpt = endpointEnum.get_current(); </li></ul><ul><li>extEnum = endpt.get_presence().get_extensions().getEnumerator(); </li></ul><ul><li>while (extEnum.moveNext()) { </li></ul><ul><li>extension = extEnum.get_current(); </li></ul><ul><li>if (extension.get_name() == EXTENSION_NAME) </li></ul><ul><li>extensionContent = extension.get_content(); </li></ul><ul><li>break ; </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  8. 8. <ul><li>Simple Demo app at demonstrates how to use Custom Presence </li></ul><ul><li>Based on Hello World app ( ) </li></ul>
  9. 9. <ul><li>To see the demo, sign in to the site twice, with two different Live IDs (Works best with two different browsers i.e. IE + Firefox) </li></ul>
  10. 10. <ul><li>Users signed into the demo are assigned a custom presence extension </li></ul><ul><li>If a contact in your list is signed into the same app, their status is shown with an asterisk * </li></ul>Contacts signed into the same demo site get a *
  11. 11. <ul><li>Demonstration App: </li></ul><ul><li>SDK docs: </li></ul><ul><li>More information at </li></ul>