chore: async stop process

This commit is contained in:
kaichaosun 2025-12-03 17:44:41 +08:00
parent 09f2af49e9
commit 76e65f49b6
No known key found for this signature in database
GPG Key ID: 223E0F992F4F03BF
4 changed files with 8 additions and 9 deletions

View File

@ -69,7 +69,7 @@ proc main() {.async.} =
await saro.start()
await raya.start()
await sleepAsync(5.seconds)
await sleepAsync(10.seconds)
# Perform OOB Introduction: Raya -> Saro
let raya_bundle = raya.createIntroBundle()
@ -77,8 +77,8 @@ proc main() {.async.} =
await sleepAsync(20.seconds) # Run for some time
saro.stop()
raya.stop()
await saro.stop()
await raya.stop()
when isMainModule:

View File

@ -106,10 +106,6 @@ proc getSelectedConvo(app: ChatApp): ptr ConvoInfo =
proc createChatClient(name: string): Future[Client] {.async.} =
var cfg = await getCfg(name)
# for key, val in fetchRegistrations():
# if key != name:
# cfg.waku.staticPeers.add(val)
result = newClient(cfg.waku, cfg.ident)

View File

@ -291,8 +291,8 @@ proc start*(client: Client) {.async.} =
notice "Client start complete", client = client.getId()
proc stop*(client: Client) =
proc stop*(client: Client) {.async.} =
## Stop the client.
client.ds.stop()
await client.ds.stop()
client.isRunning = false
notice "Client stopped", client = client.getId()

View File

@ -206,3 +206,6 @@ proc getConnectedPeerCount*(client: WakuClient): int =
if peerInfo.connectedness == Connected:
inc count
return count
proc stop*(client: WakuClient) {.async.} =
await client.node.stop()