2018-07-05 12:40:11 +01:00
|
|
|
include ../ json_rpc / client
|
2018-06-13 19:12:29 +01:00
|
|
|
|
|
|
|
proc nextId*(self: RpcClient): int64 = self.nextId
|
2018-06-11 19:26:16 +01:00
|
|
|
|
|
|
|
proc rawCall*(self: RpcClient, name: string,
|
|
|
|
msg: string): Future[Response] {.async.} =
|
|
|
|
# For debug purposes only
|
|
|
|
let id = $self.nextId
|
|
|
|
self.nextId.inc
|
2018-06-12 19:28:41 +01:00
|
|
|
|
2018-06-13 19:12:29 +01:00
|
|
|
var s = msg & "\c\l"
|
2018-07-06 17:47:43 +01:00
|
|
|
let res = await self.transport.write(s)
|
2019-03-13 22:42:07 +01:00
|
|
|
doAssert res == len(s)
|
2018-06-11 19:26:16 +01:00
|
|
|
|
|
|
|
# completed by processMessage.
|
|
|
|
var newFut = newFuture[Response]()
|
|
|
|
# add to awaiting responses
|
|
|
|
self.awaiting[id] = newFut
|
2018-06-12 19:28:41 +01:00
|
|
|
|
2018-06-11 19:26:16 +01:00
|
|
|
result = await newFut
|