Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: align with new subscription ruleset

...

Code Block
  rule mischief_who {
    select when mischief who
    pre {
      mischief = event:attr("eci")
      things = wrangler:children().map(function(v){v.{"eci"}})
                                  .filter(function(v){v != mischief})
    }
    always {
      ent:mischief := mischief;
      ent:things := things
    }
  }

...

Code Block
  rule mischief_subscriptions {
    select when mischief subscriptions
    pre {
      mischief = ent:mischief
      thing1 = ent:things[0]
      thing2 = ent:things[1]
    }
    if mischief && thing1 && thing2 then every {
      event:send(
        { "eci": mischief, "eid": "subscription",
          "domain": "wrangler", "type": "subscription",
          "attrs": { "name": "thing1",
                     "nameRx_spacerole": "mischiefthing",
                     "myTx_role": "controller",
                     "subscriber_role": "thing",
                     "channel_type": "subscription",
                     "subscriberwellKnown_eciTx": thing1 } } )
      event:send(
        { "eci": mischief, "eid": "subscription",
          "domain": "wrangler", "type": "subscription",
          "attrs": { "name": "thing2",
                     "nameRx_spacerole": "mischiefthing",
                     "myTx_role": "controller",
                     "subscriber_role": "thing",
                     "channel_type": "subscription",
                     "subscriberwellKnown_eciTx": thing2 } } )
    }
  }

The ruleset also sets up a button in the owner pico's Testing tab, "mischief/subscriptions" to send the event that causes this rule to evaluate. Navigate to the Testing tab for the Owner Pico to click on this button.

The final step is that a rule selecting on wrangler/inbound_pending_subscription_added is in each of the thing picos (the ruleset mischief.thing), and this will complete the subscription process. You can see the results by refreshing the UI and navigating to the Subscriptions tab for any of the picos involved in one or both of the two subscriptions.

...