Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
themeConfluence
titleGiven a Collection Pico's WellKnown add self to CollectionSend a Welcome Message to New Collection Members
rule onNewCollectionMember {
  select when collection new_member
  pre {
    subInfo = event:attr("bus") // Same attributes as given to wrangler subscription_added
  }
  event:send({"eci":subInfo{"Tx"}, "domain":"example","type":"welcome_to_collection"})
}

...

Messages can be sent to collection members by using the return value of the members() function to loop through members with a foreach and send an event to each Tx.

They can also be sent by raising the wrangler:send_event_to_collection_members API event. It internally uses the Rx_role of the collection pico in the subscription so be wary of collisions. 

Code Block
languagejs
themeConfluence
titleSend an Event to All Collection Members
rule sendEventToNodes {
  select when test test
  always {
    raise wrangler event "send_event_to_collection_members" attributes {
      "domain":"wrangler",
      "type":"child_creation",
      "attrs":{
        "name":"CreatedBySubscription"
      }
    }
  }
}