Click to Rate and Give Feedback
MSDN
MSDN Library
Live Services SDK
 How to: Change the User's Status

  Switch on low bandwidth view
How to: Change the User's Status

You can easily enable a user to change his or her Windows Live Messenger status by using either the Display Picture ControlPresence Status Control or the Profile Control.

To enable a user to change status with the Windows Live Messenger Library, you should call the set_status accessor function of the presence object for the user.

To change the user's status
  • Call set_status, as shown in the following example.

    _user.get_presence().set_status(Microsoft.Live.Messenger.PresenceStatus.online);

The following code example shows a simple interface to change the user's status. The JavaScript code contains an array of the selectable PresenceStatus values, and a function that changes the status when a value is chosen from a drop-down list (<select> element). The HTML contains the UI code.

Example

JavaScript
function selectStatusChanged() 
{
    var selectStatus = Document.GetElementById('selectStatus');
    var presenceStatus = [
Microsoft.Live.Messenger.PresenceStatus.appearOffline,
Microsoft.Live.Messenger.PresenceStatus.away,
Microsoft.Live.Messenger.PresenceStatus.beRightBack,
Microsoft.Live.Messenger.PresenceStatus.busy,
Microsoft.Live.Messenger.PresenceStatus.idle,
Microsoft.Live.Messenger.PresenceStatus.inACall,
Microsoft.Live.Messenger.PresenceStatus.online,
Microsoft.Live.Messenger.PresenceStatus.outToLunch ];
    if (_user.get_presence().get_status() !== Microsoft.Live.Messenger.PresenceStatus.offline) 
    {
        _user.get_presence().set_status(presenceStatus[selectStatus.selectedIndex]);
    }
}
HTML
<div>
    <p>Change Your Status:</p>
    <select id="selectStatus" onchange="selectStatusChanged()">
        <option>Appear Offline</option>
        <option>Away</option>
        <option>Be Right Back</option>
        <option>Busy</option>
        <option>Idle</option>
        <option>In a Call</option>
        <option selected>Online</option>
        <option>Out to Lunch</option>
    </select>
</div>
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker