11
Windows Live Messenger Windows Live Messenger Library Library Custom Presence

Custom Presence in the Windows Live Messenger Library

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Custom Presence in the Windows Live Messenger Library

Windows Live Messenger Windows Live Messenger LibraryLibrary

Custom Presence

Page 2: Custom Presence in the Windows Live Messenger Library

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

Page 3: Custom Presence in the Windows Live Messenger Library

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

Page 4: Custom Presence in the Windows Live Messenger Library

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

Page 5: Custom Presence in the Windows Live Messenger Library

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);}

Page 6: Custom Presence in the Windows Live Messenger Library

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'));

Page 7: Custom Presence in the Windows Live Messenger Library

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

Page 8: Custom Presence in the Windows Live Messenger Library

Simple Demo app at http://wlmlcustompresence.mslivelabs.com demonstrates how to use Custom Presence

Based on Hello World app (http://wlmlhelloworld.mslivelabs.com)

Page 9: Custom Presence in the Windows Live Messenger Library

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)

Page 10: Custom Presence in the Windows Live Messenger Library

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 *

Page 11: Custom Presence in the Windows Live Messenger Library

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