C# Lync Client SDK:接收可用性
我制作了一个小应用程序,当我的一个联系人的可用性发生变化时,可以对其进行更新。目前我只记录这个 我在这里找到了一个很棒的资源: 其基本建议如下:C# Lync Client SDK:接收可用性,c#,.net,lync-2013,lync-client-sdk,skype-for-business,C#,.net,Lync 2013,Lync Client Sdk,Skype For Business,我制作了一个小应用程序,当我的一个联系人的可用性发生变化时,可以对其进行更新。目前我只记录这个 我在这里找到了一个很棒的资源: 其基本建议如下: //Register to a contact Contact contactByUri = _lyncClient.ContactManager.GetContactByUri(user.UserUri); contactByUri.ContactInformationChanged += new EventHandler(Self_ContactI
//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.
如果可用性是以下情况之一:
//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有时无法报告实际联系人可用性的好理由。我有时在UCMA代码中也会看到这一点,在UCMA代码中,我可以为用户订阅状态更新,在回调事件中,我会收到他们的AggregatePresenceState为null的通知 我还没有深入研究它,但也许将Lync客户端日志设置为最大详细度,并使用Snooper工具或使用Wireshark检查跟踪会发现收到的损坏的SIP NOTIFY消息 另外,值得注意的是,SDK中用于将原始整数ContactInformationType.Availability值解析为ContactAvailability枚举值()的Microsoft示例代码与其自身的规范()不匹配,因此示例代码会导致无效的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();
然后尝试使用
contact.GetContactInformation(ContactInformationType.DisplayName).ToString()+" "+ contact.GetContactInformation(ContactInformationType.Availability).ToString();
我还看到Lync API在没有明显原因的情况下随机无法提供PrimaryEmailAddress和ContactEndpoints