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 output triggers

As we did for the other observable resources we added to the sensor, we need to specify when the output resource is to be triggered. We mimic the motion detector setup in that we first add a longer interval of 1 minute to let the subscriber know the subscription is active:

this.outputResource?.TriggerAll(new TimeSpan(0, 1, 0)); 

We then update the SetOutput method to trigger the resource whenever the resource is changed, whether internally or from an incoming request:

internal async Task SetOutput(bool On, string Actor) 
{ 
   ... 
 
   this.outputResource?.TriggerAll(); 
} 

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