在 Lync 中检测来电

发布于 2025-01-03 22:00:02 字数 374 浏览 1 评论 0原文

我正在尝试在 Lync 客户端中检测来电。这是通过在 Lync 客户端中订阅 ConversationManager.ConversationAdded 事件来完成的,如 此中所述post

但是,通过使用此方法,如果在呼叫者呼叫之前与呼叫者的对话窗口已打开,我将无法检测来电。 例如,如果我正在与朋友聊天,因此打开了对话窗口,并且该朋友决定给我打电话,则不会触发 ConversationAdded 事件。

当我已经与呼叫者进行有效对话时,如何检测来电?

谢谢, 尼克拉斯

I'm trying to detect an incoming call in the Lync client . This is done by subscribing to ConversationManager.ConversationAdded event in the Lync client as described in this post

However, by using this method I'm not able to detect incoming calls if a conversation window with the caller is already open before the caller is calling.
For instance if I'm chatting with a friend and therefore have a open conversation windows and this friend decides to call me, the ConversationAdded event is not triggered.

How would I detect incoming calls when I already have an active conversation with the caller?

Thanks,
Nicklas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗梦空间 2025-01-10 22:00:02

您需要监视对话模式的状态。两种可用的模式是 IM 和 AV,因此您需要监视这些模式的状态更改,如下所示:

void ConversationManager_ConversationAdded(object sender, Microsoft.Lync.Model.Conversation.ConversationManagerEventArgs e)
{
    e.Conversation.Modalities[ModalityTypes.InstantMessage].ModalityStateChanged += IMModalityStateChanged;
    e.Conversation.Modalities[ModalityTypes.AudioVideo].ModalityStateChanged += AVModalityStateChanged;
}

void IMModalityStateChanged(object sender, ModalityStateChangedEventArgs e)
{
    if (e.NewState == ModalityState.Connected)
        MessageBox.Show("IM Modality Connected");
}

void AVModalityStateChanged(object sender, ModalityStateChangedEventArgs e)
{
    if (e.NewState == ModalityState.Connected)
        MessageBox.Show("AV Modality Connected");
}

此示例使用 ConversationAdded 事件来连接模式更改的事件处理程序,因此这仅适用于以下对话:在您的应用程序运行时启动。要对应用程序启动之前已处于活动状态的对话执行相同的操作,您可以将此代码添加到应用程序的启动例程中:

foreach (var conv in _lync.ConversationManager.Conversations)
{
    conv.Modalities[ModalityTypes.InstantMessage].ModalityStateChanged += new EventHandler<ModalityStateChangedEventArgs>(IMModalityStateChanged);
    conv.Modalities[ModalityTypes.AudioVideo].ModalityStateChanged += new EventHandler<ModalityStateChangedEventArgs>(AVModalityStateChanged);
}

You need to monitor the states of the modalities on the conversation. The two avaiable modalities are IM and AV, so you'll need to watch for state changes on these, like so:

void ConversationManager_ConversationAdded(object sender, Microsoft.Lync.Model.Conversation.ConversationManagerEventArgs e)
{
    e.Conversation.Modalities[ModalityTypes.InstantMessage].ModalityStateChanged += IMModalityStateChanged;
    e.Conversation.Modalities[ModalityTypes.AudioVideo].ModalityStateChanged += AVModalityStateChanged;
}

void IMModalityStateChanged(object sender, ModalityStateChangedEventArgs e)
{
    if (e.NewState == ModalityState.Connected)
        MessageBox.Show("IM Modality Connected");
}

void AVModalityStateChanged(object sender, ModalityStateChangedEventArgs e)
{
    if (e.NewState == ModalityState.Connected)
        MessageBox.Show("AV Modality Connected");
}

This sample is using the ConversationAdded event to wire up the event handlers for modality changes, so this will only work for conversations that are started while your application is running. To do the same for conversations that are already active before your application starts, you could add this code to your application's startup routine:

foreach (var conv in _lync.ConversationManager.Conversations)
{
    conv.Modalities[ModalityTypes.InstantMessage].ModalityStateChanged += new EventHandler<ModalityStateChangedEventArgs>(IMModalityStateChanged);
    conv.Modalities[ModalityTypes.AudioVideo].ModalityStateChanged += new EventHandler<ModalityStateChangedEventArgs>(AVModalityStateChanged);
}
薄荷→糖丶微凉 2025-01-10 22:00:02

您应该订阅 Conversation.Modalities[ModalityTypes.AudioVideo] 上的 ModalityStateChanged 事件,这将在创建 AV 模态或更改状态时为您提供事件。

You should subscribe to the ModalityStateChanged event on Conversation.Modalities[ModalityTypes.AudioVideo], this will give you events when the AV modality is created or changes state.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文