mixinafJsonRpc::JsonRpc
afJsonRpc::JsonRpc
An implementation of JSON-RPC v2.
- call
- abstract Str? call(InStream jsonIn)- Invokes the (batch of) RPCs for the given JSON request, and returns the JSON response. - nullis returned, should the request be a notification.
- make
- static new make(Obj sink, [Str:Obj]? opts := null)- Creates an instance of - JsonRpc.- sinkmay either a single instance, or a- Str:Objmap of sink instances where- Stris a prefix that must match the RPC method name.- jsonRpc := JsonRpc([ "text/" : TextSink() "image/" : ImageSink() ])- Options defaults are: - pathDelimiter : '/' errFn : |JsonRpcErr rpcErr | { } fromJsonFn : |Obj? jsonVal, Type argType ->Obj?| { jsonVal } toJsonFn : |Obj? returnVal ->Obj?| { returnVal } rpcHookFn : |Obj sink, Method method, Obj?[]? args->Obj?| { method.callOn(sink, args) }- fromJsonFnis used to convert method arguments and- toJsonFnis used to convert the method's return value.- rpcHookFnallows you to intercept the final method invocation, make changes, and optionally continue with the invocation.
- toImmutableFn
- abstract |InStream->Str? toImmutableFn()- Converts this class into an immutable function. - Note that the handler and all options must be immutable too.