コード例 #1
0
ファイル: SubscribePresence.cs プロジェクト: mujiansu/Lync
 // Event handler to process remote target's presence subscription state
 // changes
 private void RemotePresence_SubscriptionStateNotificationReceived(object sender,
                                                                   RemoteSubscriptionStateChangedEventArgs e)
 {
     foreach (RealTimeAddress address in e.SubscriptionStateChanges.Keys)
     {
         if (address.Uri == _remoteUserUri)
         {
             Console.WriteLine("Target {0} subscription state has changed from {1} to {2}",
                               _remoteUserUri,
                               e.SubscriptionStateChanges[address].PreviousState,
                               e.SubscriptionStateChanges[address].State);
         }
     }
 }
コード例 #2
0
        private void PresenceView_SubscriptionStateChanged(object sender, RemoteSubscriptionStateChangedEventArgs e)
        {
            var presenceView = (RemotePresenceView)sender;
            var request      = (CallbackRequest)presenceView.ApplicationContext;

            foreach (var pair in e.SubscriptionStateChanges)
            {
                if (pair.Value.State == RemotePresentitySubscriptionState.Terminating)
                {
                    this.RemoveRequest(request);
                    break; // We have only one target in the view. So, we should see this only once for the target.
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Log the subscription states that have changed.
        /// </summary>
        /// <param name="sender">
        /// View that saw subscription state changes.
        /// </param>
        /// <param name="e">Data about the state changes</param>
        private void RemotePresenceView_SubscriptionStateChanged(
            object sender,
            RemoteSubscriptionStateChangedEventArgs e)
        {
            // Extract the view that raised the event.
            RemotePresenceView view = sender as RemotePresenceView;

            // The event args can contain multiple StateChanged notifications
            foreach (KeyValuePair <RealTimeAddress, RemotePresentityStateChange> stateChanged in
                     e.SubscriptionStateChanges)
            {
                Console.WriteLine("\nView: " + view.ApplicationContext
                                  + "; SubscriptionState for user: "******" has changed from: " + stateChanged.Value.PreviousState
                                  + " to: " + stateChanged.Value.State + ".");
            }
        }
コード例 #4
0
        void RemoteSubscriptionStateChanged(object sender, RemoteSubscriptionStateChangedEventArgs e)
        {
            bool completeAction = false;

            lock (m_syncRoot)
            {
                foreach (KeyValuePair <RealTimeAddress, RemotePresentityStateChange> pair in e.SubscriptionStateChanges)
                {
                    if (pair.Value.PreviousState == RemotePresentitySubscriptionState.Subscribing)
                    {
                        m_subCount++; // Went from subscribing to some other state. Could be Terminating or Subscribed or WaitingForRetry etc.
                    }
                }
                if (m_subCount == m_contacts.Count)
                {
                    completeAction = true;
                }
                if (completeAction && m_presenceWaitAction != null)
                {
                    m_presenceWaitAction.Complete(null);
                }
            }
        }
コード例 #5
0
 void PersistentSubscriptionStateChangedEventHandler(object sender, RemoteSubscriptionStateChangedEventArgs e)
 {
     if (OnPersistentSubscriptionStateChanged != null)
         RaiseEvent(OnPersistentSubscriptionStateChanged, this, e);
 }