Lync客户端SDK:接收有时奇怪的ContactAvailability

本文关键字:ContactAvailability 客户端 SDK Lync | 更新日期: 2023-09-27 17:51:12

我做了一个小的应用程序,当我的一个联系人的可用性发生变化时,它允许我更新。目前我只记录这个

我找到了一个很好的资源:https://rcosic.wordpress.com/2011/11/17/availability-presence-in-lync-client/

基本建议如下:

//Register to a contact
Contact contactByUri = _lyncClient.ContactManager.GetContactByUri(user.UserUri);
contactByUri.ContactInformationChanged += new EventHandler(Self_ContactInformationChanged);
void Self_ContactInformationChanged(object sender, ContactInformationChangedEventArgs e)
{
    Contact self = sender as Contact;
    // has user changed his availability (therefore, his presence status)?
    if (e.ChangedContactInformation.Contains(ContactInformationType.Availability))
    {
        ContactAvailability availability = (ContactAvailability)self.GetContactInformation(ContactInformationType.Availability);
        string activity = (string)self.GetContactInformation(ContactInformationType.Activity);
        OnAvailabilityChanged(availability, activity);
    }
}

可用性是下列之一:

Invalid (-1),
None (0) – Do not use this enumerator. This flag indicates that the cotact state is unspecified.,
Free (3500) – A flag indicating that the contact is available,
FreeIdle (5000) – Contact is free but inactive,
Busy (6500) – A flag indicating that the contact is busy and inactive,
BusyIdle (7500) – Contact is busy but inactive,
DoNotDisturb (9500) – A flag indicating that the contact does not want to be disturbed,
TemporarilyAway (12500) – A flag indicating that the contact is temporarily away,
Away (15500) – A flag indicating that the contact is away,
Offline (18500) – A flag indicating that the contact is signed out.

大多数时候,一切都很好,但有些日子,我收到一个ContactAvailability = None

我想知道为什么,如果我能做些什么来解决这个问题?(如重置客户端sdk,…)?

Lync客户端SDK:接收有时奇怪的ContactAvailability

我从来没有想过Lync有时不能报告实际联系人可用性的原因。我有时也在UCMA代码中看到这种情况,在那里我可以订阅用户的状态更新,并且在回调事件中,我得到通知,他们的AggregatePresenceState为空。

我还没有深入研究它,但也许将Lync客户端日志记录设置为最大的冗长并使用Snooper工具或使用Wireshark检查跟踪会显示收到的损坏的SIP NOTIFY消息?

另外,值得注意的是,SDK中用于解析原始整数ContactInformationType的Microsoft示例代码。可用性值转换为ContactAvailability enum值(https://msdn.microsoft.com/en-us/library/office/jj937284.aspx)与它们自己的规范(https://msdn.microsoft.com/en-us/library/cc431501(v=office.12).aspx)不匹配。遵循示例代码会导致无效的0可用性值被解释为Online

你可以试试这个。

 List < ContactInformationType > contactInformationList = new List<ContactInformationType>();
 //contactInformationList.Add(ContactInformationType.Activity);
 contactInformationList.Add(ContactInformationType.Availability);
// contactInformationList.Add(ContactInformationType.CapabilityString);              
 ContactSubscription contactSubscription = 
LyncClient.GetClient().ContactManager.CreateSubscription();

并添加您想订阅的联系人

contactSubscription.AddContact(contact);                         
contactSubscription.Subscribe(ContactSubscriptionRefreshRate.High,contactInformationList);

,然后尝试使用

查询可用性
contact.GetContactInformation(ContactInformationType.DisplayName).ToString()+"   "+ contact.GetContactInformation(ContactInformationType.Availability).ToString();
相关文章:
  • 没有找到相关文章