sendEventToRelays method

  1. @override
void sendEventToRelays(
  1. SentNostrEvent event, {
  2. void onOk(
    1. NostrEventOkCommand ok
    )?,
})
override

This method is responsible for sending an event to all relays that you did registered with the init method.

It takes a NostrEvent object, then it serializes it internally and sends it to all relays WebSockets.

example:

Nostr.instance.relays.sendEventToRelays(event);

Implementation

@override
void sendEventToRelays(
  SentNostrEvent event, {
  void Function(NostrEventOkCommand ok)? onOk,
}) {
  final serialized = event.serialized();
  _registerOnOklCallBack(event.id, onOk);

  _runFunctionOverRelationIteration((relay) {
    relay.socket.add(serialized);
    NostrClientUtils.log(
      "event with id: ${event.id} is sent to relay with url: ${relay.url}",
    );
  });
}