onReceive method

  1. @override
void onReceive(
  1. LocalityEvent localityEvent
)
override

React to events being thrown. Use switch case on the localityEvent.event

Implementation

@override
void onReceive(LocalityEvent localityEvent) {
  scheduledEvents.add(localityEvent);
  if (!scheduled) {
    scheduled = true;
    timeline.whenSynchronized(() {
      scheduledEvents.sort((LocalityEvent a, LocalityEvent b) {
        int timeDifference = a.servertime - b.servertime;
        if (timeDifference == 0) {
          return a.uuid.compareTo(b.uuid);
        }
        return timeDifference;
      });
      onReceiveInOrder(scheduledEvents);
      scheduled = false;
    });
  }
}