Reputation: 20761
I've made a small application, which allows me to be updated when one of my contact has is availability changing. Currently I only log this.
I've found a great ressource here: https://rcosic.wordpress.com/2011/11/17/availability-presence-in-lync-client/
Which basically advise the following:
//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);
}
}
Where Availability is one of the following:
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.
Most of the time, everything is working fine, but some days, I receive a ContactAvailability
= None
.
I would like to know why, and if there is something I can do to resolve this issue?(Like reset client sdk, ...)?
Upvotes: 1
Views: 1165
Reputation: 1
you can try this.
List < ContactInformationType > contactInformationList = new List<ContactInformationType>();
//contactInformationList.Add(ContactInformationType.Activity);
contactInformationList.Add(ContactInformationType.Availability);
// contactInformationList.Add(ContactInformationType.CapabilityString);
ContactSubscription contactSubscription =
LyncClient.GetClient().ContactManager.CreateSubscription();
and add the contact you would like to subscribe
contactSubscription.AddContact(contact);
contactSubscription.Subscribe(ContactSubscriptionRefreshRate.High,contactInformationList);
and then try to query for the availability using the
contact.GetContactInformation(ContactInformationType.DisplayName).ToString()+" "+ contact.GetContactInformation(ContactInformationType.Availability).ToString();
Upvotes: 0
Reputation: 474
I've never figured out a good rhyme or reason for why Lync sometimes fails to report the real contact availability. I see this sometimes in UCMA code as well, where I can subscribe to presence updates for a user, and in the callback event, I get notifications that their AggregatePresenceState is null.
I haven't dug into it yet, but perhaps setting the Lync client logging to maximum verbosity and inspecting the traces with the Snooper tool or using Wireshark would reveal corrupted SIP NOTIFY messages received?
Also, it is worth noting that the Microsoft sample code in the SDK for parsing the raw integer ContactInformationType.Availability value into a ContactAvailability enum value (https://msdn.microsoft.com/en-us/library/office/jj937284.aspx) does not match their own specifications (https://msdn.microsoft.com/en-us/library/cc431501(v=office.12).aspx) Following the sample code results in invalid 0 availability values being interpreted as Online.
Upvotes: 1