简体   繁体   English

不允许来电Lync Api或为来电禁用声音

[英]Do not allow incoming call Lync Api or disabling sounds for incoming call

I have developed a windows application using Lync api. 我已经使用Lync api开发了Windows应用程序。 My client want to disable incoming calls to this application. 我的客户想要禁用对此应用程序的传入呼叫。 So i have added some thing like this. 所以我添加了一些类似的东西。 I am able to cut the call but there are few rings before im able to do that 我可以挂断电话,但是在我无法拨打电话之前只有几声铃响

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;
     }
    }
  }

I do not know if there is a way to capture conversation before Conversation_Added event. 我不知道在Conversation_Added事件之前是否有捕获对话的方法。 However, if the Lync status is not of any relevance to you then you change the Lync Status to "Do not disturb". 但是,如果Lync状态与您无关,则可以将Lync Status更改为“请勿打扰”。 This way you would never get any incoming request (unless the user Lync setting allow to do so) 这样,您将永远不会收到任何传入请求(除非用户Lync设置允许这样做)

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 {}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM