It seems that having e4 nested/child event under e3 (Parent event) doesn’t guarantee what we want which is to match the following order e3→e4, sometimes we are matching e4→e3. Probably because e3 listener is always on due to “on all“
note: we cannot use in our case something similar to:
”on all Event(type=GEO_FENCE_IN_TYPE) as e3 → Event(type=GEO_FENCE_OUT_TYPE) as e4 {“
because e3 and e4 are from the same device and they will never (or rarely) happen consecutively, in most cases some events from other devices will be between e3 and e4
also we need to find a way to harden this code for the following scenario: if by chance IN event is received 5 times and only 1 OUT is received, we don’t want this OUT to match all the 5 INs, it should match only 1
on all Event(type=IN_TYPE) as e3 {
on wait (2.0)
and not Event(type=IN_TYPE, source=e3.source) { // Terminate wait listener if IN_TYPE even arrives within 2 seconds
on Event(type=OUT_TYPE, source=e3.source) as e4 within(43200.0)
and not Event(type=IN_TYPE, source=e3.source) { // Terminate listener for OUT_TYPE if another IN_TYPE event arrives for the same source
//...
}
}
}
so for part1, is it confirmed that with the initial code that I shared, OUT can be matched before IN? I thought that separating the OUT and the IN by ‘on wait (2.0‘ will force the OUT to be received at least 2 seconds after the IN so OUT would never accepted if it was received same time as IN or before IN. In other words if OUT is a child/nested under a parent IN, this already doesnt guarantee by default (even without on wait) that IN should be received before OUT?
for part2: adding not event for on wait “ on wait (2.0)
and not Event(type=IN_TYPE, source=e3.source) {“ this will practically terminate the wait listener if for example IN#2 was received within 2 seconds of IN#1 correct? that’s needed. So lets consider this scenario : 2 INs received within 2 seconds followed by OUT after 1 min:
IN#1 is matched (using on all)→ Wait listener is activated→ IN#2 is received→ wait listener deactivated, also IN#2 is matched (using on all)→ OUT is matching (using nested child on): that’s what we need
concerning “ on Event(type=OUT_TYPE, source=e3.source) as e4 within(43200.0)
and not Event(type=IN_TYPE, source=e3.source)“ we don’t want that, we want this OUT to match only 1 of the INs (which happened before it(, in this scenario this OUT will be completely discarded since its listener will be terminated