Live Services Synchronizing Life
Communications – Messenger, Presence, Alerts and Activities
1
Agenda • • • • • •
Live Services Synchronizing Life
Overview Messenger Library Messenger IM Control Presence API Alerts Activities
2
Session objectives and takeaways
Live Services Synchronizing Life
• Understand the strategic importance of using Live Messenger in your applications • Understand the various Live Messenger components • Know your development options for
3
Overview
Live Services Synchronizing Life
• Why Live Messenger? • Compelling way for people to stay in touch • 300+ Million Users (world’s largest) • 30 Billion contact relationships • #1 messaging service in most markets • Grow audience and user base • Increase stickiness of your site
4
Build Rich Social Apps
Live Services Synchronizing Life
• Reach out to contacts • Add new contacts • Show what users are doing on your site • Let users interact with rich messaging
5
Demo
Live Services Synchronizing Life
Tafiti
6
Communications within the Live Framework
Live Services Synchronizing Life
Libraries .NET FX 3.5 APIs
Silverlight APIs
JavaScript APIs
Client Controls
Web Controls
Tools & Services
…
Resource Model ATOM AtomPub
JSON
POX
RSS
Binary XML
Developer Portal
FeedSync
CRUD
Sync
Resource Scripts
URI-LINQ
Triggers
Data
Core
Device Mesh Applications
Folders
News
Photos
Favorites
Contacts
Groups
Profile
Calendar
Hosting
Introspection
Communications
App Model
P2P
Catalog
Notifications
Hosting
Presence
Mesh Applications
User
Identity
Auth/Z
App Data & Settings Application Management
System
Provisioning / Account Management
Visual Studio Tools / Designers
Geospatial Search
Live Operating Environment
Analytics
CRUD
Sync
Cache
CRUD
Sync
Hosting
Resource Script Engine
Auth/Z
Analytics
Resource Script Engine
Auth/Z
Local Store
…
P2P
File Sys
…
Client
Cloud Windows “Strata”
Windows
Embedded
Windows Mobile
Developer Sandbox Other
Windows Live Messenger
Live Services Synchronizing Life
Enables third-party sites to seamlessly add instant messaging capabilities with Windows Live Messenger Client-side library helps build presence-enabled Web applications Messenger Library applications can be built in JavaScript or C# (using Script#) Sign-in with Windows Live ID; sign-in control hosted by Microsoft Interact with site visitors or other IM users
Windows Live Messenger Library Messaging and Presence Build a custom Messenger experience All of the core Windows Live Messenger features are available Application Messages and Custom Presence allow value-added features
Live Services Synchronizing Life
Live Services Synchronizing Life
What’s new in Messenger Library 2.5 • •
Live Services Synchronizing Life
JavaScript URL is http://www.wlmessenger.net/api/2.5/ messenger.js Contact Properties 1. Presence 2. Display Name 3. Nickname
• • • •
Endpoint Names Show/Hide Control All collections expose item accessors Firefox 3.0 support
11
User requirements
Live Services Synchronizing Life
• Windows Live ID is required • End users must grant permission to each web site that hosts a client library application – The user may allow the site to sign them in to Messenger
• Browser support – IE 6, 7 & 8 – Firefox 1.5, 2.0 & 3.0 – Safari 3.0 12
Live Services Synchronizing Life
Messenger Library
13
Development with Messenger Library •
Live Services Synchronizing Life
Sign-in 1. Instantiate Microsoft.Live.Messenger.UI.SignInControl 2. Subscribe to the AuthenticationCompleted event 3. Define event handler for AuthenticationCompleted 1. 2. 3.
Instantiate User object Subscribe to User.SignInCompleted Call User.SignIn
4. Define event handler for User.SignInCompleted 5. After authentication the User object is ready to use •
•
User Object 1. Represents signed in user 2. Provides access to user’s contact Channel and Privacy pages 1. Required to host these pages 2. Channel.htm used for cross-domain communication 14
Monitoring Presence (status)
Live Services Synchronizing Life
• Monitor the presence of the current user and the user’s contacts • Iterate through each contact on the user's contact list 1.Subscribe to the PropertyChanged event 2.Subscribe to the ContactPresence
15
Monitoring Online/Offline
Live Services Synchronizing Life
• Use the User.OnlineContacts and User.OfflineContacts collections • Setup CollectionChanged event handlers for each collection • Update the UI with the event handlers
_user.get_onlineContacts().add_collection Changed(onlineContacts_CollectionChanged); _user.get_offlineContacts().add_collection Changed(offlineContacts_CollectionChanged); 16
Changing User Presence
Live Services Synchronizing Life
• Use the set_status function of the presence object for the user _user.get_presence().set_status(Microsoft .Live.Messenger.PresenceStatus.online) ;
17
Managing User Contacts
Live Services Synchronizing Life
• Get contact collection _contactCollection = _user.get_contacts();
• Subscribe to AddContactCompletedEventHandler _user.add_addContactCompleted(addContactCompl eted);
• Add a Contact _user.addContact(address, 'Invitation message.', null);
• Remove a contact var contact = _contactCollection.find(address, 18
Manage Conversations
Live Services Synchronizing Life
• Create an instance of a conversation
var imaddress = contact.get_currentAddress(); _conv = _user.get_conversations().create(imaddress);
• Send a message
var message = new Microsoft.Live.Messenger.TextMessage(“A message.", null); _conv.sendMessage(message, null);
• Listen for a message
_conv.add_messageReceived(recvMsg);
• Track conversations 19
Live Services Synchronizing Life
Presence API
20
Presence API
Live Services Synchronizing Life
• Show a user’s presence • User must give permission to share presence and receive messages • HTTP based API • Returns JSON or an image • Can be used together with IM Control • Supported browsers – IE 6 or higher – Firefox 1.5 or higher on Windows 21
Developing Online Presence •
• • • •
Live Services Synchronizing Life
Invite users with Signup URL 1. http://settings.messenger.live.com/applications/ websignup.aspx?returnurl=[URL]&privacyurl=[URL] Users will be returned to the return URL Must implement a privacy page Returned CID can be used by both the Presence API and the IM control Query the Presence API using HTTP http:// messenger.services.live.com/users/[ID]/[resource]/[? queryparameters] 1. [ID] is numerical user ID 2. [resource] specifies JSON or image
22
JSON Presence Result
Live Services Synchronizing Life
{ "status": "Online", "icon": { "height": 16, "url": "http://settings.messenger.live.com/static/w13r2/Conversation/ img/Status_Online.gif", "width": 16 }, "statusText": "Online", "id": "
[email protected]", "displayName": "Name" }
23
Querying Presence
Live Services Synchronizing Life
• cb query parameter - JSON 1. http://messenger.services.live.com/users/
[email protected]/presence/? cb=ShowStatus&mkt=en-US
• Presence image from an HTML
element 1.
24
JSON Elements Element
Description
status
Online, Away, Idle, BeRightBack, Busy, OutToLunch The user's status as a localized string. OnThePhone, Offline The ID that was passed in to the API call.
statusText id
Live Services Synchronizing Life
displayNam The Messenger display name of the user. e mkt Specifies a culture ID indicating the language. icon icon.url
References an icon representing the user’s status. The URL of the status icon image.
icon.width
The width of the status icon image in pixels.
icon.height
The height of the status icon image in pixels.
25
Demo
Live Services Synchronizing Life
Simple API DEMO
26
Live Services Synchronizing Life
Messenger Control
Messenger IM Control
Live Services Synchronizing Life
• Navigate to: • http://settings.messenger.live.com/applications/ websettings.aspx • Select the Allow websites to see your Messenger status and send you messages check box and click Save • Under Web Settings, click Create HTML • Copy the HTML and paste it into your Web page
28
Inviting Users • • • •
Live Services Synchronizing Life
Add a link to the signup page. User goes to WLM settings page. Redirect back to the web site Use the users ID with the IM control
29
Demo
Live Services Synchronizing Life
Create IM control HTML http://settings.messenger.live.com/applications/ WebSettings.aspx
30
Live Services Synchronizing Life
Alerts
Alerts SDK
Live Services Synchronizing Life
• SOAP Protocol • Programmatic Integration – – – – – –
Add/Remove group Publication sign-up Subscribe/Unsubscribe end-user Deliver message Inquire about user subscription Inquire about available groups
32
Live Services Synchronizing Life
33
Security
Live Services Synchronizing Life
• Partner Identification – Each Alerts Partner is provided with a unique PIN and password. – The PIN and password are required in all message transmissions to Alerts.
• Partner IP – Alerts validates each request against a specified list of legal IP addresses. This list of addresses must be supplied to Alerts and verified before the site can operate in production mode. 34
Production and Testing Environments •
Live Services Synchronizing Life
Testing URIs – Message: http://services.alerts.live-ppe.com/axis/services/Message – Subscription: http://services.alerts.live-ppe.com/axis/services/Subscription
•
Production URIs – Message: http://services.alerts.live.com/axis/services/Message – Subscription: http://services.alerts.live.com/axis/services/Subscription
•
Alerts Manager URLs – Test: http://signup.alerts.live-ppe.com/login/editLoginPIN.do – Production: http://signup.alerts.live.com/login
•
End-user Signup URLs – Test: http://signup.alerts.live-ppe.com/alerts/login.do? PINID=
&returnURL= – Production: http:// signup.alerts.live.com/alerts/login.do? 35
Live Services Synchronizing Life
Activities
Windows Live Messenger
Live Services Synchronizing Life
• A Messenger Activity is a Web application page that provides an interactive experience for Windows Live Messenger users • Activities can be multi-user applications take advantage of the Messenger communication infrastructure • Users start Activities from the Games or the Activities buttons in a conversation window, or externally from a webpage.
Windows Live Messenger Activities Example: Windows Live Search Activity
Live Services Synchronizing Life
Windows Live Messenger Activities Example: Windows Live Search Activity
Live Services Synchronizing Life
Windows Live Messenger
Live Services Synchronizing Life
Getting Started
Start with a new or existing HTML page. The HTML page will be displayed within the Windows Live Messenger client The largest window that the Windows Live Messenger client can display is 500 by 500 pixels Event handlers and functions are placed in the scripting part of the document Output and information are displayed in the body part of the document.
Activity Object Model
Live Services Synchronizing Life
•
Channel Object—Contains properties, methods, and events for sending and receiving data and for interacting with the chat history window.
•
Error Object—Contains properties for presenting error information to the user.
•
FileInfo Object—Contains properties for determining the status of a file transfer.
•
Messenger Object—Contains methods for launching client dialog pages.
•
User Object—Contains properties for ascertaining user name, e-mail address, and Live ID Unique ID (UID) of conversants.
•
Users Collection- The top-level collection of User objects.
41
Windows Live Messenger Activities
Live Services Synchronizing Life
Event Handling •
•
•
When a Windows Live Messenger Activity is running, the Windows Live Messenger script engine is firing events to the application. In order for two instances of the application to communicate with each other, appropriate event handlers must be defined. For example, if the SendData method is used to send a string from one instance to the other, an OnDataReceived event handler must be defined to receive the string. Some commonly used event handlers are: – – – – – –
OnRemoteAppLoaded OnRemoteAppClosed OnDataReceived OnDataError OnTypeChanged OnAppClose
Windows Live Messenger Activities
Live Services Synchronizing Life
Multi-User Activities •
Multi-user activities can exchange data and synchronize between two instances
•
The following processes make up the foundation of a multi-user Windows Live Messenger Activity: – Synchronizing • •
The first application to load calls Channel.Initialize, and then waits for the event Channel.OnRemoteAppLoaded to fire. The second application calls Channel.Initialize when it is ready to communicate, and the event Channel.OnRemoteAppLoaded fires immediately.
– Sending and receiving data • •
Similar to Single User Activities, the primary way to send information is by the method Channel.SendData. An application must have an event handler called Channel.OnDataReceived; this event fires when the application receives data. The method Channel.SendFile can be used to transfer files. If used, the application must also have an event handler for Channel.OnFileReceived.
– Error handling • •
Again similar to Single User Activities, An application should have an event handler for Channel.OnDataError. This event fires if Channel.SendData fails. Typically, an application should try to send the data again, in case the error was an isolated communication problem.
Standard vs. Advanced Applications • • •
Live Services Synchronizing Life
Activities run in a sandbox Basic features are unrestricted Advanced features – Permission Flags – ActiveX—Required to host ActiveX controls on the application Web page. – EnableIP—Required to get the IP addresses for the computers running the application. – PassportSiteID—Required to perform Live ID authentication, or to get the user name or e-mail address of a participant. – ReceiveIM—Required to view the contents of incoming chat messages. – ReplaceIM—Required to intercept and replace the contents of incoming chat messages. – SendFile—Required to send files as part of the application. – SendIM—Required to send a chat message to the remote user, either as the local user or as the application. – UserProperties—Required to perform Live ID authentication, or to get the 44
Special Permissions
Live Services Synchronizing Life
• Several Activity features require special approval: – – – – –
Sending and receiving instant messages Sending files Hosting ActiveX controls Getting the client IP address Using Windows Live ID authentication
• To implement these features, you must request them by writing to the Windows Live Support alias ([email protected]). • You must provide a detailed description explaining why special permissions are needed and how they will be used. In addition, the Windows Live Support team may ask you to supply code for your application that details how you will implement the features.
Development Languages and
Live Services Synchronizing Life
•
Build with ASP, VBScript, C, C++, C#, others
•
Must not contain any functionality found in the Messenger client. – Instant messaging – File transfer (for example, digital photos or sound files) – Audio conversation capabilities – Control of a Web camera or use of a video conferencing session – Application sharing – Creation of a white board space 46
Submission Process
Live Services Synchronizing Life
• Download the Activity SDK from MSDN at http:// msdn.microsoft.com/live/msnmessenger/. • Develop your Activity and perform pre-review compliance testing of the application, as specified in the SDK. • Submit your Activity for final review at http:// gallery.live.com/ before it is enabled for use by Messenger users. • Activity is reviewed based on features and review requirements. • Windows Live notifies you when the Activity is enabled for
Documentation
Live Services Synchronizing Life
• Functional spec – Special permissions and features (next slide)
• Test plan – Demonstrate compliance with requirements
• Test case documentation – Test case details
48
Other requirements
Live Services Synchronizing Life
• Must have IE 5.01 or later installed • Must include help • ActiveX controls must be signed – You must handle the case where the control is not installed.
• Additional software requirements – Notify user that 3rd party software is required – Check if already installed 49
Testing
Live Services Synchronizing Life
• Copy MSGRP2P.xml – Copy to 2 computers if multi user
• XML changes – Tic Tac Toe – http://server/app/defaulthtm URL>
50
Demo
Live Services Synchronizing Life
Sample Activity
51
Windows Live Messenger Activities Get Started •
Messenger Development on Windows Live Dev http://dev.live.com/messenger
•
Activity API SDK http://msdn2.microsoft.com/en-us/library/aa751024.aspx
Live Services Synchronizing Life
Questions?
Live Services Synchronizing Life
Discussion
Live Services Synchronizing Life
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.