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

Making new friends

When we have identified a device we need access to, we need to update our roster accordingly by annotating the contact with the corresponding groups. If a roster item already exists, we update it. If one does not exist, we add one. We also need to send a presence subscription to the corresponding device, if one is not already available, to be able to communicate with it:

 RosterItem Item = this.xmppClient[this.sensorJid]; if (Item != null) { this.xmppClient.UpdateRosterItem(this.sensorJid, Item.Name, this.AddReference(Item.Groups, "Sensor", Thing.Node)); if (Item.State != SubscriptionState.Both && Item.State != SubscriptionState.To) { this.xmppClient.RequestPresenceSubscription( this.sensorJid); } } else { this.xmppClient.AddRosterItem( ...

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