View
4.768
Download
0
Category
Preview:
DESCRIPTION
Overview deck of the custom presence features in the Windows Live Messenger Library
Citation preview
Windows Live Messenger Windows Live Messenger LibraryLibrary
Custom Presence
Custom Presence allows your web application to set custom presence properties on Messenger users
Uses:Detect when two users are both signed into your custom Messenger applicationEnables sharing of rich presence information between users of your web application
This allows you to ‘light up’ extra features between multiple users who are signed into your site
Create a presence extension objectThis object must support the get_name() methodOther methods/data are up to you
Create a PresenceExtensionFactory object with two methods:
serialize(property): output a string representation of the presence extension objectdeserialize(name, content): recreate the presence extension from the string representation
Set your PresenceExtensionFactory as the active presence factory
Add the presence extension to users’ presence
This Presence Extension stores simple name/value pairs – they can be fancier
var EXTENSION_NAME = ‘ExtNm’ // 6 chars or less
function MyPresenceExtension(name, content) { this.name = name; this.content = content;}
MyPresenceExtension.prototype.get_name = function() { return this.name;}
MyPresenceExtension.prototype.get_content = function() { return this.content;}
This object serializes and deserializes your custom presence extension
MyPresenceFactory = function () {}
MyPresenceFactory.prototype.serialize = function(prop) { return prop.get_content();}
MyPresenceFactory.prototype.deserialize = function(name, content) { return new MyPresenceExtension(name, content);}
Add your presence factory to the user object
user.set_presenceFactory(new MyPresenceFactory());
Add your presence extension to the signed-in user endpointColl = user.get_endpoints();endpointPresence = endpointColl.get_item(0).get_presence();extensionColl = endpointPresence.get_extensions();extensionColl.add(new
MyPresenceExtension(EXTENSION_NAME,'Content'));
For each contact, check their endpoints for the presence extension
endpointEnum = address.get_endpoints().getEnumerator();while (endpointEnum.moveNext()) { endpt = endpointEnum.get_current(); extEnum = endpt.get_presence().get_extensions().getEnumerator(); while (extEnum.moveNext()) { extension = extEnum.get_current(); if (extension.get_name() == EXTENSION_NAME) extensionContent = extension.get_content(); break; }}
Simple Demo app at http://wlmlcustompresence.mslivelabs.com demonstrates how to use Custom Presence
Based on Hello World app (http://wlmlhelloworld.mslivelabs.com)
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)
Users signed into the demo are assigned a custom presence extension
If a contact in your list is signed into the same app, their status is shown with an asterisk *
Contacts Contacts
signed into the signed into the same demo same demo site get a *site get a *
Demonstration App:http://wlmlcustompresence.mslivelabs.com/
SDK docs: http://msdn2.microsoft.com/en-us/library/cc298458.aspx
More information at http://dev.live.com/messenger
Recommended