Windows Live Messenger Library Development Basics

You can use the Windows Live Messenger Library to create a full-featured Web-based messaging application. This topic provides a high-level overview of the objects and events you will work with while creating a Web-based messaging application.

This topic contains the following subtopics:

Signing in to Live Messenger

The User Object

The Channel and Privacy Pages

JavaScript IntelliSense

Signing in to Messenger

To sign in to Windows Live™ Messenger, users must first be authenticated with Windows Live. Delegated Authentication enables an application to authenticate a user with Windows Live without prompting the user for a username and password. In order for an application to use Delegated Authentication, the application must first request consent from the user and the user must provide consent for the application.

After a user grants consent, the application provider will receive a consent token. This consent token can then be used to authenticate a user and sign in to Messenger. The user only needs to grant consent on the first sign in. Subsequently, the application can store the consent token and use it to authenticate the user for all future sessions.

The DelegatedAuthControl is designed to help abstract the functionality that is required to request consent from a user. For a new user, the sequence of events when signing in is as follows:

  • The user clicks the DelegatedAuthControl and a dialog box appears.
  • The dialog box will prompt the user to sign in, if the user is not already authenticated.
  • After authentication, the user is redirected to a page that prompts the user for permission to allow the application to sign in on the user's behalf.
  • The user grants permission for the application to use Delegated Authentication.
  • The application receives a consent token when the request is granted.
  • The application decrypts the consent token to retrieve the delegation token.
  • The application uses the delegation token to authenticate the user for the current and any subsequent sessions.
The User Object

All messaging activity depends upon the User object (Microsoft.Live.Messenger.User class), which represents the user who is currently signed in. You can access the User object from the Sign In control. Use the User object to give the user access to his or her Contact list, so that a user can add or remove contacts, monitor the presence status of contacts, send and receive messages, and receive invitations from other users.

The User object is created when an authenticated user is signed in to the Messenger service by using a Windows Live ID. Users can only sign in by using the Sign In control. The User object exists only for the life of the Web page. A single instance can be accessed after a user is signed in. The User object is disposed when the user navigates away from the page, refreshes the page, or closes the browser.

The Channel and Privacy Pages

Web sites that integrate the Sign In control are required to host a channel page and a privacy page. The channel page must be hosted on the same domain as the application itself.

The channel page facilitates cross-domain communication between your application domain and the Windows Live service domain ("live.com"). The code for this page is supplied, and you should not alter it prior to use. The privacy page displays your Web site's privacy policy to site visitors. The following code example shows the code to use for the channel page.

Channel.htm

<html >
<head>
<title>Channel</title>
<meta name="ROBOTS" content="NONE"/>
<script type="text/javascript">
function onLoad()
{
    try
    {
        var hash = window.location.hash.substr(1);
        if (window.location.replace == null)
        {
            window.location.replace = window.location.assign;
        }
        window.location.replace("about:blank");
        var name = hash.split("/")[0];
        var win = null;
        if (name && (name != ".parent"))
        {
            win = window.parent.frames[name];
        }
        else
        {
            win = window.parent.parent;
        }
        if (win.Microsoft)
        {
            win.Microsoft.Live.Channels.Mux._recv_chunk(hash);
        }
    }
    catch (ex)
    {
        /* ignore */
    }
}
</script>
</head>
<body onload="onLoad();"></body>
</html>
JavaScript IntelliSense

If you're using Microsoft® Visual Studio® 2008, you can enable JavaScript Intellisense for the Windows Live Messenger Library by adding a pair of JavaScript files to your project and adding the following lines to the top of the JavaScript file that you're working with:

/// <reference path="MicrosoftAjaxCore.js" />
/// <reference path="Microsoft.Live.Messenger.documentation.js" />

These references must be local because referencing remote files is not currently supported for JavaScript Intellisense.

You can download the files from:

Right-click each hyperlink, and then click Save As to save the file to your local computer.

See Also

Concepts

Windows Live Messenger Library Tasks

Page view tracker