(buf *strings.Builder, methodDecl *wshrpc.WshRpcMethodDecl)
| 95 | } |
| 96 | |
| 97 | func GenMethod_ResponseStream(buf *strings.Builder, methodDecl *wshrpc.WshRpcMethodDecl) { |
| 98 | fmt.Fprintf(buf, "// command %q, wshserver.%s\n", methodDecl.Command, methodDecl.MethodName) |
| 99 | dataType, dataVarName := getWshMethodDataParamsAndExpr(methodDecl) |
| 100 | respType := "any" |
| 101 | if methodDecl.DefaultResponseDataType != nil { |
| 102 | respType = methodDecl.DefaultResponseDataType.String() |
| 103 | } |
| 104 | fmt.Fprintf(buf, "func %s(w *wshutil.WshRpc%s, opts *wshrpc.RpcOpts) chan wshrpc.RespOrErrorUnion[%s] {\n", methodDecl.MethodName, dataType, respType) |
| 105 | fmt.Fprintf(buf, "\treturn sendRpcRequestResponseStreamHelper[%s](w, %q, %s, opts)\n", respType, methodDecl.Command, dataVarName) |
| 106 | fmt.Fprintf(buf, "}\n\n") |
| 107 | } |
| 108 | |
| 109 | func getWshMethodDataParamsAndExpr(methodDecl *wshrpc.WshRpcMethodDecl) (string, string) { |
| 110 | dataTypes := methodDecl.GetCommandDataTypes() |
no test coverage detected