Monitoring Presence (JavaScript Library)

Ff752467.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.

You can monitor the presence of a current Windows Live Messenger user and the user's contacts. Monitoring presence is useful to track a user's presence and other properties, such as a display picture or display message text.

You can monitor presence for the signed in user by adding an event handler for Microsoft.Live.IMessengerContext.OnUserPresenceChanged.

To monitor presence for the signed in user
  1. Call onUserPresenceChanged in the messengerContext instance, passing the event handler function name.

    messengerContext.onUserPresenceChanged(onUserPresenceChanged);
    
    
  2. Create the event handler function

    function onUserPresenceChanged(name, value) {
        Sys.Debug.trace(name + " has changed to " + value + ".");
    }
    

You can monitor presence for all of the signed in user's contacts by adding an event handler for Microsoft.Live.IMessengerContext.OnContactPresenceChanged.

To subscribe to the CollectionChanged event
  1. Call onUserPresenceChanged on the messengerContext instance, passing the event handler function name.

    messengerContext.onContactPresenceChanged(onContactPresenceChanged);
    
    
  2. Create the event handler function.

    function onContactPresenceChanged(cid, name, value) {
        Sys.Debug.trace("User " + cid + " " + name + " has changed to " + value + ".");
    }
    
Show: