mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-25 22:13:12 +00:00
Node API: Implement basic subscribe topic (#89)
* Fix init signature according to Node API See https://github.com/status-im/nim-waku/blob/master/docs/api/v2/node.md * Update docs and example * Node API: Basic subscribe * Modify example with subscribe handler
This commit is contained in:
+10
-7
@@ -15,15 +15,18 @@ import ../../waku/node/v2/wakunode2
|
||||
# Loads the config in `waku/node/v2/config.nim`
|
||||
let conf = WakuNodeConf.load()
|
||||
|
||||
# Create and start the node
|
||||
#proc runBackground(conf: WakuNodeConf) {.async.} =
|
||||
# init(conf)
|
||||
# runForever()
|
||||
# Node operations happens asynchronously
|
||||
proc runBackground(conf: WakuNodeConf) {.async.} =
|
||||
# Create and start the node
|
||||
let node = await init(conf)
|
||||
|
||||
discard init(conf)
|
||||
|
||||
echo("Do stuff after with node")
|
||||
# Subscribe to a topic
|
||||
let topic = "foobar"
|
||||
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
|
||||
info "Hit subscribe handler", topic=topic, data=data
|
||||
node.subscribe(topic, handler)
|
||||
|
||||
discard runBackground(conf)
|
||||
runForever()
|
||||
|
||||
# TODO Lets start with Nim Node API first
|
||||
|
||||
Reference in New Issue
Block a user