O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Invalidating existing friendships

If more than a day has passed, and we still do not get data from the sensor, we invalidate the connection, and remove the annotations we have stored for the corresponding roster item:

else if (SecondsSinceLastEvent > 60 * 60 * 24) 
{ 
   if (!string.IsNullOrEmpty(this.sensorJid)) 
   { 
         Item = this.xmppClient[this.sensorJid]; 
 
         this.sensor = null; 
         this.sensorJid = null; 
 
         if (Item != null) 
         { 
               this.xmppClient.UpdateRosterItem(this.sensorJid, 
                     Item.Name, this.RemoveReference(Item.Groups, 
                     "Sensor")); 
         } 
   } 
 
   Search = true; 
} 
Here, the RemoveReference() method removes the groups used for annotating the roster item, and that is used by the AddReference() and GetReference() methods. See the GitHub repository for details.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required