From 8685135fe90de4bebc497377fb215196fc1537e0 Mon Sep 17 00:00:00 2001 From: coffeepots Date: Tue, 26 Jun 2018 15:40:09 +0100 Subject: [PATCH] Update comments --- rpc/server.nim | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/rpc/server.nim b/rpc/server.nim index 0bbd1fe..db7d309 100644 --- a/rpc/server.nim +++ b/rpc/server.nim @@ -111,9 +111,9 @@ proc genErrorSending(name, writeCode: NimNode): NimNode = ## Send error message to client let error = %{"code": %(code), "id": id, "message": %msg, "data": data} debug "Error generated", error = error, id = id - var - value {.inject.} = wrapReply(id, newJNull(), error) + template client: untyped = clientTrans + var value {.inject.} = wrapReply(id, newJNull(), error) `res` = `writeCode` proc `sendJsonErr`*(state: RpcJsonError, clientTrans: RpcClientTransport, id: JsonNode, @@ -152,8 +152,8 @@ proc genProcessMessages(name, sendErrorName, writeCode: NimNode): NimNode = %(methodName & " is not a registered method.")) else: let callRes = await server.procs[methodName](node["params"]) - var value {.inject.} = wrapReply(id, callRes, newJNull()) template client: untyped = clientTrans + var value {.inject.} = wrapReply(id, callRes, newJNull()) asyncCheck `writeCode` proc genProcessClient(nameIdent, procMessagesIdent, sendErrIdent, readCode, afterReadCode, closeCode: NimNode): NimNode = @@ -228,12 +228,21 @@ macro defineRpcServerTransport*(procClientName: untyped, body: untyped = nil): u case verb.toLowerAscii of "write": + # `client`, the RpcClient + # `value`, the data returned from the invoked RPC writeCode = code of "read": + # `client`, the RpcClient + # `maxRequestLength`, set to defaultMaxRequestLength + # Result of expression is awaited readCode = code of "close": + # `client`, the RpcClient + # Access to `value`, which contains the data read by `readCode` closeCode = code of "afterread": + # `client`, the RpcClient + # Access to `value`, which contains the data read by `readCode` afterReadCode = code else: error("Unknown RPC verb \"" & verb & "\"")