From d5116b07bb3e7ee2f49d178fb69c39ed4029d3c2 Mon Sep 17 00:00:00 2001 From: coffeepots Date: Thu, 21 Jun 2018 18:22:04 +0100 Subject: [PATCH] Updated comments --- rpc/server.nim | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/rpc/server.nim b/rpc/server.nim index 383876f..6dff5af 100644 --- a/rpc/server.nim +++ b/rpc/server.nim @@ -192,34 +192,22 @@ proc genProcessClient(nameIdent, procMessagesIdent, sendErrIdent, readCode, clos await clientTrans.`sendErrIdent`(SERVER_ERROR, "Error: Unknown error occurred", %"") -#[ - New API: - For custom RpcServers that do their own work upon getting/sending data. - - newServer = defineRpcServer[StreamTransport, StreamServer]: - write: - mySpecialWriter(server, client, line) - # Note: Anything not defined here will use the default code to operate - - Code is directly inserted into processMessages. You can still define your - own transports, but this lets you define operations for existing transports - without needing to rework them. -]# - -import random - macro defineRpcTransport*(procClientName: untyped, body: untyped = nil): untyped = ## Build an rpcServer type that inlines data access operations #[ Injects: - line: to be populated by the transport + client: RpcClientTransport type + maxRequestLength: optional bytes to read + value: Json string to be written to transport Example: defineRpcTransport(myServer): write: - write("http://" & value) + client.write(value) read: - readLine + client.readLine(maxRequestLength) + close: + client.close ]# procClientName.expectKind nnkIdent var