mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-05-28 05:19:26 +00:00
commit
af33cb9fbc
@ -62,7 +62,7 @@ proc processMessage*(self: RpcClient, line: string) =
|
|||||||
|
|
||||||
if not self.awaiting.hasKey(id):
|
if not self.awaiting.hasKey(id):
|
||||||
raise newException(ValueError,
|
raise newException(ValueError,
|
||||||
"Cannot find message id \"" & node["id"].str & "\"")
|
"Cannot find message id \"" & $node["id"].getInt & "\"")
|
||||||
|
|
||||||
let version = checkGet(node, "jsonrpc", JString)
|
let version = checkGet(node, "jsonrpc", JString)
|
||||||
if version != "2.0":
|
if version != "2.0":
|
||||||
|
|||||||
@ -21,14 +21,16 @@ method call*(self: RpcSocketClient, name: string,
|
|||||||
if self.transport.isNil:
|
if self.transport.isNil:
|
||||||
raise newException(ValueError,
|
raise newException(ValueError,
|
||||||
"Transport is not initialised (missing a call to connect?)")
|
"Transport is not initialised (missing a call to connect?)")
|
||||||
let res = await self.transport.write(value)
|
|
||||||
# TODO: Add actions when not full packet was send, e.g. disconnect peer.
|
|
||||||
doAssert(res == len(value))
|
|
||||||
|
|
||||||
# completed by processMessage.
|
# completed by processMessage.
|
||||||
var newFut = newFuture[Response]()
|
var newFut = newFuture[Response]()
|
||||||
# add to awaiting responses
|
# add to awaiting responses
|
||||||
self.awaiting[id] = newFut
|
self.awaiting[id] = newFut
|
||||||
|
|
||||||
|
let res = await self.transport.write(value)
|
||||||
|
# TODO: Add actions when not full packet was send, e.g. disconnect peer.
|
||||||
|
doAssert(res == len(value))
|
||||||
|
|
||||||
result = await newFut
|
result = await newFut
|
||||||
|
|
||||||
proc processData(client: RpcSocketClient) {.async.} =
|
proc processData(client: RpcSocketClient) {.async.} =
|
||||||
|
|||||||
@ -23,12 +23,13 @@ method call*(self: RpcWebSocketClient, name: string,
|
|||||||
raise newException(ValueError,
|
raise newException(ValueError,
|
||||||
"Transport is not initialised (missing a call to connect?)")
|
"Transport is not initialised (missing a call to connect?)")
|
||||||
# echo "Sent msg: ", value
|
# echo "Sent msg: ", value
|
||||||
await self.transport.send(value)
|
|
||||||
|
|
||||||
# completed by processMessage.
|
# completed by processMessage.
|
||||||
var newFut = newFuture[Response]()
|
var newFut = newFuture[Response]()
|
||||||
# add to awaiting responses
|
# add to awaiting responses
|
||||||
self.awaiting[id] = newFut
|
self.awaiting[id] = newFut
|
||||||
|
|
||||||
|
await self.transport.send(value)
|
||||||
result = await newFut
|
result = await newFut
|
||||||
|
|
||||||
proc processData(client: RpcWebSocketClient) {.async.} =
|
proc processData(client: RpcWebSocketClient) {.async.} =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user