addEvent method
Rings one event and returns its id — the handle an item action is invoked with, and the only way a reporter can tie a row back to whatever it was reporting on. Zero when the core has stopped and nothing was ringed.
Implementation
int addEvent(
String channel,
Map<String, Object?> payload, {
String? rid,
Map<String, Object?>? details,
}) {
if (_stopped) return 0;
var safe = jsonSafeMap(payload);
var event = RingEvent(_nextEventId++, channel, DateTime.now(), rid, safe);
if (details != null) _stashDetails(event.id, details);
var ring = _ring.putIfAbsent(channel, Queue.new);
ring.add(event);
while (ring.length > ringSize) {
ring.removeFirst();
}
onEvent?.call(channel, safe);
if (_attached.isNotEmpty) _broadcast(event.toFrame());
return event.id;
}