示例#1
0
        // Event handler to process ContactGroupServices notifications
        private void ContactGroupServices_NotificationReceived(object sender,
                                                               ContactsGroups.ContactGroupNotificationEventArgs e)
        {
            foreach (NotificationItem <ContactsGroups.Contact> contactNotification in e.Contacts)
            {
                Console.WriteLine("Notification received for contact = {0} for operation {1}.",
                                  contactNotification.Item.Name,
                                  contactNotification.Operation);
            }
            foreach (NotificationItem <ContactsGroups.Group> groupNotification in e.Groups)
            {
                Console.WriteLine("Notification received for group = {0} with id = {1} for operation {2}.",
                                  groupNotification.Item.Name,
                                  groupNotification.Item.GroupId,
                                  groupNotification.Operation);

                if (groupNotification.Item.Name == _groupName && groupNotification.Operation
                    == PublishOperation.Add)
                {
                    // Store the groupId for group created
                    // Note: This sample stores it as a scalar value, but it is
                    // highly recommended that you store the groupIds as a list
                    // for all groups you create
                    _groupId = groupNotification.Item.GroupId;

                    // Signal that the groupId was set
                    _waitForGroupIdSet.Set();
                }
            }
        }
        // Handler for the NotificationsReceived event on the ContactGroupServices class.
        private void ContactGroupServices_NotificationReceived(object sender,
                                                               ContactsGroups.ContactGroupNotificationEventArgs e)
        {
            List <RemotePresentitySubscriptionTarget> targets = new List <RemotePresentitySubscriptionTarget>();

            foreach (NotificationItem <ContactsGroups.Contact> contactNotification in e.Contacts)
            {
                if (contactNotification.Operation == PublishOperation.Add)
                {
                    foreach (int id in contactNotification.Item.GroupIds)
                    {
                        if (id == (int)_groupID)
                        {
                            targets.Add(new RemotePresentitySubscriptionTarget(contactNotification.Item.Uri));
                        }
                    }
                }
            }
            _remotePresenceView.StartSubscribingToPresentities(targets);
        }