client support for rpc cancel (#249)

This commit is contained in:
Mike Sawka
2024-08-19 15:44:30 -07:00
committed by GitHub
parent 00958b8fed
commit 534fcc5d0a
5 changed files with 52 additions and 22 deletions
+11 -1
View File
@@ -51,7 +51,11 @@ async function* rpcResponseGenerator(
return;
}
const shouldTerminate = yield msg.data;
if (shouldTerminate || !msg.cont) {
if (shouldTerminate) {
sendRpcCancel(reqid);
return;
}
if (!msg.cont) {
return;
}
}
@@ -65,6 +69,12 @@ async function* rpcResponseGenerator(
}
}
function sendRpcCancel(reqid: string) {
const rpcMsg: RpcMessage = { reqid: reqid, cancel: true };
const wsMsg: WSRpcCommand = { wscommand: "rpc", message: rpcMsg };
globalWS.pushMessage(wsMsg);
}
function sendRpcCommand(msg: RpcMessage): AsyncGenerator<RpcMessage, void, boolean> {
const wsMsg: WSRpcCommand = { wscommand: "rpc", message: msg };
globalWS.pushMessage(wsMsg);