feat: subscribing to signals

This commit is contained in:
Richard Ramos 2020-05-07 14:20:18 -04:00
parent ab84bb8796
commit c95e7db187
No known key found for this signature in database
GPG Key ID: 80D4B01265FDFE8F
4 changed files with 27 additions and 10 deletions

View File

@ -1,10 +1,10 @@
[Package] # Package
version = "0.1.0"
author = "Richard Ramos"
description = "A new awesome nimble package"
license = "MIT"
srcDir = "src"
bin = "nim_status_client"
[Deps] version = "0.1.0"
Requires: "nim >= 1.0.0, nimqml >= 0.7.0" author = "Your Name"
description = "Example .nimble file."
license = "MIT"
# Deps
requires "nim >= 0.10.0"

View File

@ -1,5 +1,12 @@
import NimQml import NimQml
import status import status
import libstatus
var signalHandler: SignalCallback = proc(p0: cstring): void =
setupForeignThreadGc()
echo $p0
tearDownForeignThreadGc()
QtObject: QtObject:
type ApplicationLogic* = ref object of QObject type ApplicationLogic* = ref object of QObject
@ -17,6 +24,11 @@ QtObject:
discard status.addPeer("enode://2c8de3cbb27a3d30cbb5b3e003bc722b126f5aef82e2052aaef032ca94e0c7ad219e533ba88c70585ebd802de206693255335b100307645ab5170e88620d2a81@47.244.221.14:443") discard status.addPeer("enode://2c8de3cbb27a3d30cbb5b3e003bc722b126f5aef82e2052aaef032ca94e0c7ad219e533ba88c70585ebd802de206693255335b100307645ab5170e88620d2a81@47.244.221.14:443")
echo status.callPrivateRPC("{\"jsonrpc\":\"2.0\", \"method\":\"wakuext_requestMessages\", \"params\":[{\"topics\": [\"0x7998f3c8\"]}], \"id\": 1}") echo status.callPrivateRPC("{\"jsonrpc\":\"2.0\", \"method\":\"wakuext_requestMessages\", \"params\":[{\"topics\": [\"0x7998f3c8\"]}], \"id\": 1}")
# Experiment
status.setSignalHandler(signalHandler)
# ¯\_(ツ)_/¯ dunno what is this # ¯\_(ツ)_/¯ dunno what is this
proc setup(self: ApplicationLogic) = proc setup(self: ApplicationLogic) =
# discard status.onMessage(self.onMessage) # discard status.onMessage(self.onMessage)

View File

@ -16,4 +16,6 @@ proc callPrivateRPC*(inputJSON: cstring): cstring {.importc: "CallPrivateRPC".}
proc addPeer*(peer: cstring): cstring {.importc: "AddPeer".} proc addPeer*(peer: cstring): cstring {.importc: "AddPeer".}
# proc setSignalEventCallback*(callback: proc): void {.importc: "SetSignalEventCallback".} type SignalCallback* = proc(eventMessage: cstring): void
proc setSignalEventCallback*(callback: SignalCallback) {.importc: "SetSignalEventCallback".}

View File

@ -11,6 +11,9 @@ proc recreateDir(dirname: string) =
removeDir(dirname) removeDir(dirname)
createDir(dirname) createDir(dirname)
proc setSignalHandler*(something: SignalCallback) =
libstatus.setSignalEventCallback(something)
proc setupNewAccount*() = proc setupNewAccount*() =
# Deleting directories # Deleting directories
recreateDir(datadir) recreateDir(datadir)