Do not allow Lync Api incoming call or mute sounds for incoming call

I have developed a Windows application using Lync api. My client wants to disable incoming calls for this app. So I added something like this. I can cut the call, but there are a few rings before I can.

private void ClientInitialized(IAsyncResult result)
        {
            try
            {
                //registers for conversation related events
                //these events will occur when new conversations are created (incoming/outgoing) and removed
                client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded;
                client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Problem in adding/removing conversation", "Bella IVIS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
        {
     try
     {    
     var _client = client;
     if (e.Conversation.State == ConversationState.Active)
     {
     for (int intLoop = 0; intLoop < _client.ConversationManager.Conversations.Count; intLoop++)
     {
         _client.ConversationManager.Conversations[intLoop].End();
     }
     _client = null;
      return;
     }
    }
  }

      

+3


source to share


1 answer


I don't know if there is a way to capture the conversation before the event Conversation_Added

. However, if your Lync status has nothing to do with you, you change your Lync status to Do Not Disturb. This way you will never receive any incoming request (unless the Lync customization does it)



var newInformation =new Dictionary<PublishableContactInformationType, object>();
        newInformation.Add(PublishableContactInformationType.Availability, ContactAvailability.DoNotDisturb);

try
{
     this.lyncClient.Self.BeginPublishContactInformation(newInformation,(result) => this.lyncClient.Self.EndPublishContactInformation(result) , null);
}  catch {}

      

0


source







All Articles