User Class

Ff748006.note(en-us,MSDN.10).gifNote:
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.

Represents the currently authenticated Windows Live Messenger user.

Script:  http://js.live.net/4.1/loader.js
Feature:  Messenger.Core
Namespace:  Microsoft.Live.Messenger
 
Ff748006.alert_note(en-us,MSDN.10).gifNote

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, instantiating, and deriving from classes, see Creating Custom Client Script by Using the Microsoft Ajax Library.

Microsoft.Live.Messenger.User = function();

Type.registerClass(
    'Microsoft.Live.Messenger.User',
    null,
    Microsoft.Live.Messenger.INotifyPropertyChanged,
    Sys.IDisposable);

You can create an instance of the User object by using a Messenger context object or the Identity property that is returned by the Sign-in Control. Use the User object to manage all messaging activities such as conversations, online presence, contacts, and groups. The User object exists only as long as the hosting web page. It is destroyed when the user navigates away from the page, refreshes the page, or closes the browser. Only a single instance of the object can be accessed after a user has signed in.

When you declare the User object, you should create an event handler that detects when it becomes available. There can be a small delay between the time when you create the User object and the time when you can begin accessing its members. For more information, see Working with User Data.

The following code example demonstrates how to create a new instance of the User class and verify that it is available.


            
            
            //Get the messenger context and add an onPropertyChanged handler. 
            messengerContext = wl.App.get_messengerContext(); 
            messengerContext.add_propertyChanged(onPropertyChanged); 
            //When a messenger context property is changed, this function will be called. 
            function onPropertyChanged(sender, args) 
            {
                //If the property that changed is the user property 
                if(args.get_propertyName() == "user")
                {
                    //Get the user and determine whether the user is signed in and available. 
                    user = messengerContext.get_user(); 
                    if (user.status == Microsoft.Live.Messenger.UserStatus.signedIn)
                    {
                        alert("The user object is available"); 
                    }
                }
            }
            

Object
  Microsoft.Live.Messenger..::.User

Windows Live Messenger Connect

Supported in: 4.1

Windows Live Messenger Web Toolkit

Supported in: 3.7, 3.5, 3.1, 3.0, 2.5, 2.0, 1.0

Internet Explorer 8.0, Internet Explorer 7.0, Internet Explorer 6.0, Firefox 3.6, Firefox 3.5, Firefox 3.0, Firefox 2.0, Firefox 1.5, Chrome 4.0, Chrome 3.0, Chrome 2.0, Chrome 1.0, Safari 4.0, Safari 3.0, Opera 10.5

Show: