Merge pull request #7 from status-im/subscriptions
Obtain messages from #test
This commit is contained in:
commit
f2bb680dfa
|
@ -7,4 +7,4 @@ srcDir = "src"
|
|||
bin = "nim_status_client"
|
||||
|
||||
[Deps]
|
||||
Requires: "nim >= 1.0.0, nimqml >= 0.7.0"
|
||||
Requires: "nim >= 1.0.0, nimqml >= 0.7.0"
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
import NimQml
|
||||
import status
|
||||
import libstatus
|
||||
import json
|
||||
|
||||
|
||||
var signalHandler: SignalCallback = proc(p0: cstring): void =
|
||||
setupForeignThreadGc()
|
||||
|
||||
var jsonSignal = ($p0).parseJson
|
||||
if $jsonSignal["type"].getStr == "messages.new":
|
||||
echo $p0
|
||||
|
||||
tearDownForeignThreadGc()
|
||||
|
||||
QtObject:
|
||||
type ApplicationLogic* = ref object of QObject
|
||||
|
@ -13,10 +25,16 @@ QtObject:
|
|||
result.callResult = "Use this tool to call JSONRPC methods"
|
||||
result.setup()
|
||||
|
||||
status.setSignalHandler(signalHandler)
|
||||
|
||||
status.setupNewAccount()
|
||||
discard status.addPeer("enode://2c8de3cbb27a3d30cbb5b3e003bc722b126f5aef82e2052aaef032ca94e0c7ad219e533ba88c70585ebd802de206693255335b100307645ab5170e88620d2a81@47.244.221.14:443")
|
||||
echo status.callPrivateRPC("{\"jsonrpc\":\"2.0\", \"method\":\"wakuext_requestMessages\", \"params\":[{\"topics\": [\"0x7998f3c8\"]}], \"id\": 1}")
|
||||
|
||||
status.subscribeToTest()
|
||||
|
||||
|
||||
|
||||
# ¯\_(ツ)_/¯ dunno what is this
|
||||
proc setup(self: ApplicationLogic) =
|
||||
# discard status.onMessage(self.onMessage)
|
||||
|
|
|
@ -16,4 +16,6 @@ proc callPrivateRPC*(inputJSON: cstring): cstring {.importc: "CallPrivateRPC".}
|
|||
|
||||
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".}
|
||||
|
|
|
@ -11,6 +11,71 @@ proc recreateDir(dirname: string) =
|
|||
removeDir(dirname)
|
||||
createDir(dirname)
|
||||
|
||||
proc setSignalHandler*(something: SignalCallback) =
|
||||
libstatus.setSignalEventCallback(something)
|
||||
|
||||
proc subscribeToTest*() =
|
||||
var result = ""
|
||||
|
||||
var payload = %* {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 3,
|
||||
"method": "wakuext_startMessenger",
|
||||
"params": []
|
||||
}
|
||||
result = $libstatus.callPrivateRPC($payload)
|
||||
|
||||
payload = %* {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 3,
|
||||
"method": "wakuext_loadFilters",
|
||||
"params": [
|
||||
[{
|
||||
"ChatID":"test",
|
||||
"OneToOne":false
|
||||
}]
|
||||
]
|
||||
}
|
||||
result = $libstatus.callPrivateRPC($payload)
|
||||
|
||||
|
||||
payload = %* {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 4,
|
||||
"method": "wakuext_saveChat",
|
||||
"params": [
|
||||
{
|
||||
"lastClockValue":0,
|
||||
"color":"#51d0f0",
|
||||
"name":"test",
|
||||
"lastMessage":nil,
|
||||
"active":true,
|
||||
"id":"test",
|
||||
"unviewedMessagesCount":0,
|
||||
"chatType":2,
|
||||
"timestamp":1588940692659
|
||||
}
|
||||
]
|
||||
}
|
||||
result = $libstatus.callPrivateRPC($payload)
|
||||
|
||||
|
||||
|
||||
payload = %* {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 3,
|
||||
"method": "wakuext_chatMessages",
|
||||
"params": [
|
||||
"test", nil, 20
|
||||
]
|
||||
}
|
||||
result = $libstatus.callPrivateRPC($payload)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
proc setupNewAccount*() =
|
||||
# Deleting directories
|
||||
recreateDir(datadir)
|
||||
|
|
Loading…
Reference in New Issue