úÎW]SE=      !"#$%&'()*+,-./0123456789:;<(c) Sam T. 2013MITpxqr.sta@gmail.com experimentalportableNone13479GåKResponse used to signal that callee successufully process a procedure call and to return values from procedure. KResponse should not be sent if error occurred during RPC. Thus KResponse may be only sent from server to client.-Responses are encoded as bencoded dictionary:{ "y" : "r", "r" : [ val1,  val2, ...] } ¹Query used to signal that caller want to make procedure call to callee and pass arguments in. Therefore query may be only sent from client to server but not in the opposite direction.+Queries are encoded as bencoded dictionary:{ "y" : "q", "q" : " method_name ", "a" : [ arg1,  arg2, ...] }£Errors used to signal that some error occurred while processing a procedure call. Error may be send only from server to client but not in the opposite direction.*Errors are encoded as bencoded dictionary:{ "y" : "e", "e" : [ error_code,  human_readable_error_reason] }-Some error doesn't fit in any other category.1Occur when server fail to process procedure call.1Malformed packet, invalid arguments or bad token.:Occur when client trying to call method server don't know.IRun server using a given port. Method invocation should be done manually. = > ?@Port number to listen.Handler.ABC "  = > ?@ABC(c) Sam T. 2013MITpxqr.sta@gmail.com experimentalportableNone +4>GN1Procedure signature and implementation binded up. &Asynchonous result typically get from -- call. Used to defer return values transfer.!*Address of remote can be called by client."@Represent any error mentioned by protocol specification that +, .& might throw. For more details see .D0Alias to Socket, through might change in future.$lMethod datatype used to describe name, parameters and return values of procedure. Client use a method to invoke , server  implements$ the method to make the actual work.9We use the following fantom types to ensure type-safiety:sparam: Type of method parameters. Ordinary Tuple type used to specify more than one parameter, so for example Method (Int, Int) result will take two arguments.ƒresult: Type of return value of the method. Similarly, tuple used to specify more than one return value, so for exsample Method (Foo, Bar) (Bar, Foo)4 will take two arguments and return two values.&Name used in query.'Name of each parameter in  right to left order.(Name of each return value in  right to left order.)NIdentity procedure signature. Could be used for echo servers. Implemented as: idM = method "id" ["x"] ["y"]*¿Makes method signature. Note that order of parameters and return values are not important as long as corresponding names and types are match. For exsample this is the equal definitions: YmethodA : Method (Foo, Bar) (Baz, Quux) methodA = method "mymethod" ["a", "b"] ["c", "d"] YmethodA : Method (Bar, Foo) (Quux, Baz) methodB = method "mymethod" ["b", "a"] ["d", "c"]+HMakes remote procedure call. Throws RPCException on any error occurred., The same as + but use already opened socket.-LQuery procedure call but not wait for its results. This function returns  T value which is handle to procedure result. Actual result might be obtained with .. Unable to throw ", this might happen in . if at all.„Note that sending multiple queries at the same time to the one remote is not recommended. For exsample in the following scenario: W aa <- async theRemote .... ab <- async theRemote .... a <- await ab b <- await abit's likely that the a and bQ values will be mixed up. So in order to get correct results you need to make . before the next -..cWill wait until the callee finished processing of procedure call and return its results. Throws " on any error occurred./5Assign method implementation to the method signature.0¶Run RPC server on specified port by using list of handlers. Server will dispatch procedure specified by callee, but note that it will not create new thread for each connection.E FG!"#D$%&'()*HIJK+Address of callee.Procedure to call.(Arguments passed by callee to procedure.-Values returned by callee from the procedure., Socket to useAddress of callee.Procedure to call.(Arguments passed by callee to procedure.-Values returned by callee from the procedure.-Address of callee.Procedure to call.(Arguments passed by callee to procedure.Handle to result.. Obtained from the corresponding -.3Result values of the procedure call quered with -./ Signature.Implementation.Handler used by server.0)Port used to accept incoming connections. Method table.L !"#$%&'()*+,-./0$%&'(*)!"#+ -./0,E FG!"#D$%&'()*HIJK+,-./0L/(c) Sam T. 2013MITpxqr.sta@gmail.com experimentalportableNone1379G8*Used to validate any message by its scheme forall m. m : scheme m9Get a message scheme.:Check a message with a scheme.123456789:;<MNO 123456789:;< 89:4567;123<123456789:;<MNOP      !"#$%&'())**+,-./012345667889:;<=>?@ABCDEF'GHIJKLMNOPkrpc_7ciQj1IE4oP1yjFy6E1au7Remote.KRPC.Protocol Remote.KRPCRemote.KRPC.SchemeProtocolbenco_BFHtrKWOk25BgPruRtlSgu Data.BEncodeencodeddecodeddecodeencode fromBEncode toBEncodeKRemote KRemoteAddr KResponserespValsValNameKQuery queryMethod queryArgs ParamName MethodName ErrorCodeKError GenericError errorMessage ServerError ProtocolError MethodUnknown errorCodemkKErrorkquery kresponse withRemote sendMessage recvResponse remoteServer MethodHandlerAsync RemoteAddr RPCExceptionMethod methodName methodParams methodValsidMmethodcallcall_asyncawait==>serverKResponseSchemerscVals KQueryScheme qscMethod qscParamsKMessageschemevalidatemethodQuerySchememethodRespScheme serverError maxMsgSize$fBEncodableKResponse$fBEncodableKQuery$fBEncodableKErrorRemote HandlerBody waitResult extractArgs injectVals queryCall getResult$fExceptionRPCException"$fKMessageKResponseKResponseScheme$fKMessageKQueryKQueryScheme$fKMessageKErrorInt