From several sections of the code, we've made references to a SubscribeToSensorData() method that will be called when we're ready to subscribe to the sensor data from the sensor. We are now ready to focus on how this is done. The first thing to note is that we can only perform a subscription if we know a sensor, and if it is online:
private void SubscribeToSensorData() { RosterItem SensorItem; if (!string.IsNullOrEmpty(this.sensorJid) && (SensorItem=this.xmppClient[this.sensorJid]) != null && SensorItem.HasLastPresence && SensorItem.LastPresence.IsOnline) {
If a previous subscription exists, we make sure to unsubscribe to it. This has the effect that if stray messages are received on this subscription, they ...