在 Skype for Business 客户端中订阅状态更改

Subscribing to Presence Changes in Skype for Buisness Client

我想在我的 Skype for Buisness Client 中订阅我自己的状态更改,并尝试了来自 Lync Client SDK 的 ContactInformationChanged 事件。关于订阅存在的文档 (doc) 写道,他们还需要创建一个订阅,用我想要订阅的 ContactInformationTypes 填充它,添加我想要订阅的联系人并调用 Subscribe() 在订阅对象上。现在,除非我误解了文档,否则您仍然必须订阅 ContactInformationChanged 事件(如果您这样做的话)。问题是,即使我省略了订阅创建部分,只订阅了 ContactInformationChanged 事件,也没有什么区别。例如,如果我这样做:

        var selfContact = m_lyncClient.Self.Contact;
        selfContact.ContactInformationChanged += Contact_ContactInformationChanged;

        m_subscription = m_lyncClient.ContactManager.CreateSubscription();
        m_subscription.AddContact(selfContact);
        List<ContactInformationType> contactInformationList = new List<ContactInformationType>
        {
            ContactInformationType.Activity,
            ContactInformationType.Availability,
            ContactInformationType.ActivityId,
            ContactInformationType.CustomActivity,
        };
        m_subscription.Subscribe(ContactSubscriptionRefreshRate.High, contactInformationList);

我收到 ContactInformationChanged 的事件消息,其中 ContactInformationType 我没有指定。

我的问题:

Is the Subscription creation part even necessary?

对于您自己的联系人,不,您不需要创建订阅。

Is there a way to just get Presence Notifications of specific ContactInformationType's changing (like Availabilty for example)?

没有。您只需要像这样过滤掉所有其他回调:

private void Contact_ContactInformationChanged(object sender, ContactInformationChangedEventArgs e)
{
    if (e.ChangedContactInformation.Contains(ContactInformationType.Availability) ||
        e.ChangedContactInformation.Contains(ContactInformationType.ActivityId) ||
        e.ChangedContactInformation.Contains(ContactInformationType.CustomActivity))
    {
        OnLyncPresenceChanged();
    }
}