publishEphemeral method

FakeEvent publishEphemeral(
  1. String type, {
  2. required JsonMap resource,
  3. required JsonMap payload,
  4. JsonMap scope = const {},
  5. String? audience,
  6. Set<String>? devices,
})

Publishes an ephemeral event (no seq, never in the log) to the eventHooks.

audience makes it personal; devices names the devices of audience whose live connections get it (the gateway sends an ephemeral event only with both).

Implementation

FakeEvent publishEphemeral(
  String type, {
  required JsonMap resource,
  required JsonMap payload,
  JsonMap scope = const {},
  String? audience,
  Set<String>? devices,
}) {
  final event = FakeEvent(
    _copy({
      'id': nextId(),
      'type': type,
      'schema_version': 1,
      'occurred_at': stamp(),
      'scope': scope,
      'resource': resource,
      if (audience != null) 'audience': 'self',
      'payload': payload,
    }),
    audience: audience,
    devices: devices == null ? null : Set.unmodifiable(devices),
  );
  for (final hook in List.of(eventHooks)) {
    hook(event);
  }
  return event;
}