在Skype中为Buisness客户端订阅状态更改



我想在我的Skype for Buisness客户端中订阅我自己的状态更改,并尝试了Lync客户端SDK中的ContactInformationChanged事件。订阅presence(doc(的文档中写道,他们还需要创建一个Subscription,用我要订阅的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

我的问题:

  • 订阅创建部分是否有必要
  • 有没有办法只获取特定ContactInformationType更改的存在通知(例如Availabilty(

订阅创建部分甚至是必要的吗?

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

有没有办法只获取特定ContactInformationType更改的状态通知(例如Availability(?

否。你只需要过滤掉所有其他回调,就像这样:

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

最新更新