March 2018
Beginner to intermediate
410 pages
10h 40m
English
Now that you have presence subscriptions active for your contacts, you need to react to changes in presence. They may indicate that the corresponding device has restarted, for instance. So, you need to register an event handler that is called when presence changes for one of your contacts in the roster:
this.xmppClient.OnPresence += XmppClient_OnPresence;
Whenever your sensor signals an online presence, you should re-subscribe to it, to make sure events are delivered in a timely fashion:
private void XmppClient_OnPresence(object Sender, PresenceEventArgs e) { Log.Informational("Presence received.", e.Availability.ToString(), e.From); if (this.sensorJid != null && string.Compare(e.FromBareJID,this.sensorJid,true)==0 ...Read now
Unlock full access