Пример #1
0
        /// <summary>
        /// Send state to callback
        /// </summary>
        private void SendState()
        {
            if (callback == null)
            {
                return;
            }

            if (!sendEvent)
            {
                return;
            }


            if (lyncClient == null)
            {
                callback.WriteState("not-running", "");
                return;
            }

            if (lyncClient.State != ClientState.SignedIn)
            {
                callback.WriteState("signed-out", "");
                return;
            }

            foreach (var conv in lyncClient.ConversationManager.Conversations)
            {
                ModalityState state = conv.Modalities[ModalityTypes.AudioVideo].State;

                if (state == ModalityState.Notified)
                {
                    callback.WriteState("call-calling", "");
                    return;
                }
                if (state == ModalityState.Connecting ||
                    state == ModalityState.Connected ||
                    state == ModalityState.Joining ||
                    state == ModalityState.ConnectingToCaller)
                {
                    callback.WriteState("call-connected", "");
                    return;
                }
            }

            ContactAvailability currentAvailability = (ContactAvailability)lyncClient.Self.Contact.GetContactInformation(ContactInformationType.Availability);

            // Busy, BusyIdle, Free, FreeIdle, Away, TemporarilyAway, DoNotDisturb, Offline
            callback.WriteState(currentAvailability.ToString(), "");
        }
Пример #2
0
        /// <summary>
        /// Execute an action on a specific conversation's modality in a specific state.
        /// </summary>
        public static void InState <T>(T modality, ModalityState state, Action <T> action) where T : Modality
        {
            if (modality.State == state)
            {
                action(modality);
            }

            modality.ModalityStateChanged += (o, e) =>
            {
                if (e.NewState == state)
                {
                    action(modality);
                }
            };
        }
Пример #3
0
        void conversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            try
            {
                ModalityState newState = e.Conversation.Modalities[ModalityTypes.InstantMessage].State;
                if (newState == ModalityState.Connected || newState == ModalityState.Notified)
                {
                    _ConversationImModality = (InstantMessageModality)e.Conversation.Modalities[ModalityTypes.InstantMessage];
                }

                e.Conversation.ParticipantAdded += new EventHandler <ParticipantCollectionChangedEventArgs>(Conversation_ParticipantAdded);
                // e.Conversation.AddParticipant(client.ContactManager.GetContactByUri(RemoteUserUri));
            }
            catch (LyncClientException lce)
            {
                System.Diagnostics.Debug.WriteLine("LYnc client exception on conversationadded " + lce.Message);
            }
        }
Пример #4
0
 /// <summary>
 /// Execute an action on a modality state within all current and future conversations.
 /// </summary>
 public static void InState <T>(LyncClient client, ModalityTypes modalityType, ModalityState state, Action <Conversation, T> action) where T : Modality
 {
     OnAllConversations(client, conversation =>
     {
         var modality = (T)conversation.Modalities[modalityType];
         InState(modality, state, (T m) => action(conversation, m));
     });
 }