MCPcopy
hub / github.com/wavetermdev/waveterm / wshRpcCall

Method wshRpcCall

frontend/app/store/wshclient.ts:50–73  ·  view source on GitHub ↗
(command: string, data: any, opts: RpcOpts)

Source from the content-addressed store, hash-verified

48 }
49
50 wshRpcCall(command: string, data: any, opts: RpcOpts): Promise<any> {
51 const msg: RpcMessage = {
52 command: command,
53 data: data,
54 source: this.routeId,
55 };
56 if (!opts?.noresponse) {
57 msg.reqid = crypto.randomUUID();
58 }
59 if (opts?.timeout) {
60 msg.timeout = opts.timeout;
61 }
62 if (opts?.route) {
63 msg.route = opts.route;
64 }
65 const rpcGen = sendRpcCommand(this.openRpcs, msg);
66 if (rpcGen == null) {
67 return null;
68 }
69 const respMsgPromise = rpcGen.next(true); // pass true to force termination of rpc after 1 response (not streaming)
70 return respMsgPromise.then((msg: IteratorResult<any, void>) => {
71 return msg.value;
72 });
73 }
74
75 wshRpcStream(command: string, data: any, opts: RpcOpts): AsyncGenerator<any, void, boolean> {
76 if (opts?.noresponse) {

Calls 1

sendRpcCommandFunction · 0.90

Tested by

no test coverage detected