IMessengerContext Interface
Note: |
|---|
| Current information about Live Connect is now available in the Windows Live Developer Center. The information in the following sections is provided for legacy purposes only. |
Script: http://js.live.net/4.1/loader.js
Feature: Microsoft.Live
Namespace: Microsoft.Live
Note |
|---|
The JavaScript Library for Windows Live Messenger Connect is built by using the Microsoft Ajax Library. Microsoft Ajax exposes a type system that enables you to add object-oriented capabilities to your JavaScript code. To learn more about creating and implementing interfaces, see Creating Custom Client Script by Using the Microsoft Ajax Library. |
The following example demonstrates how to use the messenger context to authenticate a user after the user is signed in.
//Get the application context and declare namespace resources.
function appOnload(evtArgs) {
Microsoft.Live.Core.Namespace.using("wl:Microsoft.Live");
Microsoft.Live.Core.Namespace.using("msgr:Microsoft.Live.Messenger");
appContext = evtArgs.get_dataContext();
auth = wl.App.get_auth();
}
//Sign in the user and specify the onSignIn callback method.
function signInUser()
{
var status = Microsoft.Live.Messenger.PresenceStatus.online;
messengerContext.signIn(status, onSignIn);
}
//Authenticate the user. If authentication fails, display an alert. If it succeeds, get the messenger context.
function onsignIn() {
if (auth) {
if (auth.get_state() == Microsoft.Live.AuthState.failed) {
alert("Authentication failed.");
return;
}
else if (auth.get_state() == Microsoft.Live.AuthState.authenticated) {
alert("Authentication succeeded.");
}
}
}
Show:
Note: