Add example of sending from ext context

This commit is contained in:
Jazz Turner-Baggs 2025-07-25 11:24:26 -07:00
parent c19738c0d8
commit f9ed0cbb8c
No known key found for this signature in database

View File

@ -1,6 +1,7 @@
import
chronicles,
chronos
chronos,
strformat
import
waku_client
@ -10,11 +11,19 @@ proc handleMessages(pubsubTopic: string, message: seq[byte]): Future[
void] {.gcsafe, raises: [Defect].} =
info "ClientRecv", pubTopic = pubsubTopic, msg = message
proc demoSendLoop(client: WakuClient): Future[void] {.async.} =
for i in 1..10:
await sleepAsync(20.seconds)
discard client.sendMessage(&"Message:{i}")
proc main(): Future[void] {.async.} =
echo "Starting POC"
let cfg = DefaultConfig()
let client = initWakuClient(cfg, @[PayloadHandler(handleMessages)])
await client.start()
asyncSpawn client.start()
await demoSendLoop(client)
echo "End of POC"
when isMainModule: