Windows Live Messenger Web Toolkit Class Reference
User..::.OfflineContacts Property

Gets the SortedContactCollection containing all contacts that are currently offline.

Script:  http://www.wlmessenger.net/api/3.5/loader.js
Feature:  Messenger.Core
Namespace:  Microsoft.Live.Messenger
 
Syntax

JavaScript
// To retrieve:
var offlineContacts = instance.get_offlineContacts();
C# (Script#)
public SortedContactCollection OfflineContacts { get; }
Remarks

When a contact's status changes from offline to online, or vice-versa, the CollectionChanged event is fired for both OnlineContacts and OfflineContacts collections to indicate that changes have occurred within each respective collection. You can subscribe to these events to track the online/offline status of users. When a contact changes from being offline to online (or vice versa), there can be slight delays where the status of the contact does not match the collection it is in. For example, when an offline contact becomes online, there may be a short interval during which reading the status of the contact shows online and the contact remains in the offline collection. Use the OnlineContacts and OfflineContacts collections to display the users contact lists in your application. Note that these collections are sorted.
Examples

The following example demonstrates how to maintain a separate contacts structure that remains in sync with a ContactCollection.
JavaScript
            var user = null;
            var onlineContacts = [];
            var offlineContacts = [];
            
            // Handle authentication - sign the user in.
            function onAuthCompleted(sender, e) {
                user = new Microsoft.Live.Messenger.User(e.get_identity());
                user.get_onlineContacts().add_collectionChanged(onOnlineContactsChanged);
                user.get_offlineContacts().add_collectionChanged(onOfflineContactsChanged);
                user.signIn();
            }
            
            // Responsible for updating the onlineContacts array to match
            // the User.OnlineContacts collection.
            function onOnlineContactsChanged(sender, e) {
                switch (e.get_action()) {
                    case Microsoft.Live.Messenger.NotifyCollectionChangedAction.add:
                        onlineContacts.splice(e.get_newStartingIndex(), 0, e.get_newItems());
                        break;
            
                    case Microsoft.Live.Messenger.NotifyCollectionChangedAction.remove:
                        onlineContacts.splice(e.get_oldStartingIndex(), e.get_oldItems().length);
                        break;
            
                    case Microsoft.Live.Messenger.NotifyCollectionChangedAction.reset:
                        onlineContacts = new Array(sender.get_count());
            
                        for (var i = 0; i < sender.get_count(); i++) {
                            onlineContacts[i] = sender.get_item(i);
                        }
                        break;
                }
            } 
            
            // Responsible for updating the offlineContacts array to match
            // the User.OfflineContacts collection.
            function onOfflineContactsChanged(sender, e) {
                switch (e.get_action()) {
                    case Microsoft.Live.Messenger.NotifyCollectionChangedAction.add:
                        offlineContacts.splice(e.get_newStartingIndex(), 0, e.get_newItems());
                        break;
            
                    case Microsoft.Live.Messenger.NotifyCollectionChangedAction.remove:
                        offlineContacts.splice(e.get_oldStartingIndex(), e.get_oldItems().length);
                        break;
            
                    case Microsoft.Live.Messenger.NotifyCollectionChangedAction.reset:
                        offlineContacts = new Array(sender.get_count());
            
                        for (var i = 0; i < sender.get_count(); i++) {
                            offlineContacts[i] = sender.get_item(i);
                        }
                        break;
                }
            } 
            
Version Information

Windows Live Messenger Web Toolkit

Supported in: 3.5, 3.1, 3.0, 2.5, 2.0
Platforms

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

See Also

Page view tracker