Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added section on deleting subscriptions

...

Notice that the rule evaluates for each of the subscriptions. It only acts for those subscriptions with a subscriber_role of "thing", and is able to reach that pico through the outbound_eci which was established when the subscription was accepted.

Deleting subscriptions

...


Info
titleEngine Compatibility

Very soon, Wrangler will fully integrate subscriptions, so that when you delete a child pico any subscriptions it participates in will also be deleted. In the meantime, you may wish to programmatically delete such subscriptions before requesting the deletion of the child pico.

To delete a subscription, either of the picos which participate in the subscription would raise the event wrangler/subscription_cancellation including an attribute named "subscription_name" whose value is the subscription name_space concatenated with a colon and the subscription name. For example, if the Thing2 pico wanted to cancel its subscription, it might include this code in the postlude of one of its rules.

Code Block
    raise wrangler event "subscription_cancellation"
      with subscription_name = "mischief:thing2"

The raised event triggers a rule in the Subscriptions ruleset. This rule takes care of deleting both sides of the subscription.

You can also, of course, cancel a subscription manually by sending this event to either of the picos involved in the subscription.


Endnotes

This page is inspired by (and often copied verbatim from) the original fourth lesson, Lesson: Pico to Pico Subscriptions.

...