March 2018
Beginner to intermediate
410 pages
10h 40m
English
Device claims can occur either when the device is online, or when it is offline. We need to handle both cases. If the claim occurred while the device was offline, we get notified of this fact in the response to the registration call:
else
{
await RuntimeSettings.SetAsync( "ThingRegistry.Key",
string.Empty);
Log.Informational("Registration updated. Device has "+
"an owner.", new KeyValuePair<string, object>(
"Owner", e.OwnerJid));
}
By adding an event handler for the Claimed event on the ThingRegistry instance, we can react immediately to the event, if the device is online. We store the network address of the owner, as well as clear the key:
this.registryClient.Claimed += async (sender, e) => { try { await RuntimeSettings.SetAsync("ThingRegistry.Owner", ...Read now
Unlock full access