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

Adding a friend

When a new roster item has been added, you need to make sure you subscribe to its presence if it's a sensor or actuator. Otherwise, you will not be able to communicate with it properly:

private void XmppClient_OnRosterItemAdded(object Sender, 
   RosterItem Item) 
{ 
   Log.Informational("Roster item added.", Item.BareJid); 
 
   if (Item.IsInGroup("Sensor") || Item.IsInGroup("Actuator")) 
   { 
         Log.Informational("Requesting presence subscription.", 
               Item.BareJid); 
 
         this.xmppClient.RequestPresenceSubscription( 
               Item.BareJid); 
   } 
} 

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