我已经制作了一个小应用程序,当我的某个联系人的可用性发生变化时,我可以对其进行更新。目前我只记录这个。
我在这里找到了一个很好的资源: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,......)?
答案 0 :(得分:1)
我从来没有想过为什么Lync有时无法报告真正的联系可用性的好押韵或原因。我有时也会在UCMA代码中看到这一点,我可以为用户订阅状态更新,在回调事件中,我收到其AggregatePresenceState为空的通知。
我还没有挖到它,但是可能将Lync客户端日志设置为最大冗长并使用Snooper工具或使用Wireshark检查跟踪会显示收到的已损坏的SIP NOTIFY消息?
另外,值得注意的是,SDK中用于将原始整数ContactInformationType.Availability值解析为ContactAvailability枚举值(https://msdn.microsoft.com/en-us/library/office/jj937284.aspx)的Microsoft示例代码与其自己的规范不匹配(https://msdn.microsoft.com/en-us/library/cc431501(v=office.12).aspx )在示例代码之后,无效的0可用性值被解释为在线。
答案 1 :(得分:0)
你可以试试这个。
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();