diff --git a/src/nim_chat_poc.nim b/src/nim_chat_poc.nim index e40937d..56ba516 100644 --- a/src/nim_chat_poc.nim +++ b/src/nim_chat_poc.nim @@ -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: