diff --git a/README.md b/README.md index 7568635..7698908 100644 --- a/README.md +++ b/README.md @@ -332,7 +332,7 @@ The `call` procedure takes care of the basic format of the JSON to send to the s However you still need to provide `params` as a `JsonNode`, which must exactly match the parameters defined in the equivalent `rpc` definition. ```nim -import json_rpc/[rpcclient, rpcserver], asyncdispatch2, json +import json_rpc/[rpcclient, rpcserver], chronos, json var server = newRpcSocketServer("localhost", Port(8545)) diff --git a/json_rpc.nimble b/json_rpc.nimble index a25b72f..74e7768 100644 --- a/json_rpc.nimble +++ b/json_rpc.nimble @@ -9,7 +9,7 @@ skipDirs = @["tests"] requires "nim >= 0.17.3", "nimcrypto", "stint", - "asyncdispatch2", + "chronos", "httputils", "chronicles" diff --git a/json_rpc/client.nim b/json_rpc/client.nim index 8e681d3..add3e67 100644 --- a/json_rpc/client.nim +++ b/json_rpc/client.nim @@ -1,8 +1,8 @@ import tables, json, macros -import asyncdispatch2 +import chronos from strutils import toLowerAscii import jsonmarshal -export asyncdispatch2 +export chronos type ClientId* = int64 @@ -55,7 +55,7 @@ proc processMessage*[T: RpcClient](self: T, line: string) = if not self.awaiting.hasKey(id): raise newException(ValueError, "Cannot find message id \"" & node["id"].str & "\"") - + let version = checkGet(node, "jsonrpc", JString) if version != "2.0": self.awaiting[id].asyncRaise(ValueError, diff --git a/json_rpc/clients/httpclient.nim b/json_rpc/clients/httpclient.nim index a991277..cf4eedd 100644 --- a/json_rpc/clients/httpclient.nim +++ b/json_rpc/clients/httpclient.nim @@ -1,5 +1,5 @@ import json, strutils, tables -import chronicles, httputils, asyncdispatch2 +import chronicles, httputils, chronos import ../client logScope: diff --git a/json_rpc/clients/socketclient.nim b/json_rpc/clients/socketclient.nim index ee4fea3..86bdb5f 100644 --- a/json_rpc/clients/socketclient.nim +++ b/json_rpc/clients/socketclient.nim @@ -1,4 +1,4 @@ -import ../client, asyncdispatch2, tables, json +import ../client, chronos, tables, json type RpcSocketClient* = ref object of RpcClient diff --git a/json_rpc/router.nim b/json_rpc/router.nim index 90f60ca..7efa081 100644 --- a/json_rpc/router.nim +++ b/json_rpc/router.nim @@ -1,7 +1,7 @@ import - json, tables, asyncdispatch2, jsonmarshal, strutils, macros, + json, tables, chronos, jsonmarshal, strutils, macros, chronicles, options -export asyncdispatch2, json, jsonmarshal +export chronos, json, jsonmarshal type RpcJsonError* = enum rjeInvalidJson, rjeVersionError, rjeNoMethod, rjeNoId, rjeNoParams @@ -9,7 +9,7 @@ type # Procedure signature accepted as an RPC call by server RpcProc* = proc(input: JsonNode): Future[JsonNode] {.gcsafe.} - + RpcProcError* = ref object of Exception code*: int data*: JsonNode @@ -147,7 +147,7 @@ proc route*(router: RpcRouter, data: string): Future[string] {.async, gcsafe.} = # const error code and message errKind = jsonErrorMessages[errState.err] # pass on the actual error message - fullMsg = errKind[1] & " " & errState[1] + fullMsg = errKind[1] & " " & errState[1] res = wrapError(code = errKind[0], msg = fullMsg, id = id) # return error state as json result = $res & messageTerminator diff --git a/json_rpc/server.nim b/json_rpc/server.nim index b848405..9cd78c2 100644 --- a/json_rpc/server.nim +++ b/json_rpc/server.nim @@ -1,8 +1,8 @@ import json, tables, options, macros -import asyncdispatch2, router, chronicles +import chronos, router, chronicles import jsonmarshal -export asyncdispatch2, json, jsonmarshal, router, chronicles +export chronos, json, jsonmarshal, router, chronicles type RpcServer* = ref object of RootRef diff --git a/json_rpc/servers/httpserver.nim b/json_rpc/servers/httpserver.nim index 76f015e..7b01d95 100644 --- a/json_rpc/servers/httpserver.nim +++ b/json_rpc/servers/httpserver.nim @@ -1,5 +1,5 @@ import json, strutils -import chronicles, httputils, asyncdispatch2 +import chronicles, httputils, chronos import ../server logScope: