sendCountEventToRelays method

  1. @override
Future<void> sendCountEventToRelays(
  1. NostrCountEvent countEvent, {
  2. required void onCountResponse(
    1. String relay,
    2. NostrCountResponse countResponse
    ),
  3. List<String>? relays,
})
override

Implementation

@override
Future<void> sendCountEventToRelays(
  NostrCountEvent countEvent, {
  required void Function(String relay, NostrCountResponse countResponse)
      onCountResponse,
  List<String>? relays,
}) async {
  await _registerNewRelays(relays ?? relaysList!);

  final serialized = countEvent.serialized();

  _runFunctionOverRelationIteration((relay) {
    final relayUrl = relay.url;

    if (relays?.containsRelay(relayUrl) ?? true) {
      _registerOnCountCallBack(
        subscriptionId: countEvent.subscriptionId,
        onCountResponse: onCountResponse,
        relay: relayUrl,
      );

      relay.socket.sink.add(serialized);
      utils.log(
        'Count Event with subscription id: ${countEvent.subscriptionId} is sent to relay with url: ${relay.url}',
      );
    }
  });
}