attempting to call different proc inside signal handler

This commit is contained in:
Iuri Matias 2020-05-11 18:23:27 -04:00
parent 4cc2d2cd22
commit abb0c4cee6
2 changed files with 16 additions and 11 deletions

View File

@ -19,7 +19,7 @@ proc mainProc() =
var engine = newQQmlApplicationEngine()
defer: engine.delete()
status.setSignalHandler()
status.init()
status.setupNewAccount()
discard status.addPeer("enode://2c8de3cbb27a3d30cbb5b3e003bc722b126f5aef82e2052aaef032ca94e0c7ad219e533ba88c70585ebd802de206693255335b100307645ab5170e88620d2a81@47.244.221.14:443")

View File

@ -6,23 +6,28 @@ const datadir = "./data/"
const keystoredir = "./data/keystore/"
const nobackupdir = "./noBackup/"
var signalHandler: SignalCallback = proc(p0: cstring): void =
setupForeignThreadGc()
var jsonSignal = ($p0).parseJson
if $jsonSignal["type"].getStr == "messages.new":
echo $p0
tearDownForeignThreadGc()
proc recreateDir(dirname: string) =
if existsDir(dirname):
removeDir(dirname)
createDir(dirname)
proc setSignalHandler*() =
proc setSignalHandler(signalHandler: SignalCallback) =
libstatus.setSignalEventCallback(signalHandler)
proc init*() =
var onSignal: SignalCallback = proc(p0: cstring): void =
setupForeignThreadGc()
# TODO: Dispatch depending on message type $jsonSignal["type"].getStr
# Consider also have an intermediate object with an enum for type
# So you do not have to deal with json objects but with a nim type
echo $p0
tearDownForeignThreadGc()
setSignalHandler(onSignal)
proc queryAccounts*(): string =
var payload = %* {
"jsonrpc": "2.0",