...
Here is KRL code which will accept subscription requests from other picos which are becoming members of this collection. We will use subscriptions subscription roles to identify the subscriptions of interest. Doing so allows the collection pico to participate in other kinds of subscriptions. The collection pico will play the role "collection"
and the role "member"
will be played by the picos we are collecting.
...
We will name the collection pico by the prefix, a space, and "Rooms" (and will change the name manually later – we could have instead added another event attribute for the desired name). Line 2 selects on a particular event domain and type (which are also available in the "Testing" tab because of an entry in events
of __testing
). Line 11 raises the event which will create the collection pico as a child of the building pico. The specific pico name, color, and rids are established in lines 5-8. We also include the name_prefix
which is not required for the child creation, but will be needed in a later step.
...
This rule selects (line 2) on the internal event, and sets up a loop (line 3) over the desired member picos (produced by the by_prefix
function). We get an ECI for each pico from the building pico (line 5). In lines 6 and 8 we ensure, for sanity, that the pico can do subscriptions. Finally (in lines 9-13) we send each soon-to-be member pico an event asking it to request a new subscription to the collection pico with the correct roles, and with the new channels created for the subscription named by the tag_id.
...
Code Block | ||
---|---|---|
| ||
meta { use module edu.byu.enMotion.collection alias collection shares some_function } global { some_function = function() { collection:members()// some further processing } } rule some_rule { select when something required foreach collection:members() setting(subs) // some action/postludes for each subs } |
and specify additonal additional processing in some_function
(defined in lines 6-8) that it shares (in line 3) to endpoints, and/or specify rules like some_rule
(defined in lines 10-14) that take action on the collection's members when certain events occur.