MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / sendRequest

Function sendRequest

src/shared/services/stdio_service.ts:108–128  ·  view source on GitHub ↗
(method: string, params?: TReq)

Source from the content-addressed store, hash-verified

106 protected notifyRequestAfterExit() { }
107
108 protected sendRequest<TReq, TResp>(method: string, params?: TReq): Promise<TResp> {
109 // Generate an ID for this request so we can match up the response.
110 const id = this.nextRequestID++;
111
112 return new Promise<TResp>((resolve, reject) => {
113 if (this.processExited) {
114 this.notifyRequestAfterExit();
115 reject(`Tried to call "${method}" but process has already exited with code ${this.process?.exitCode}`);
116 return;
117 }
118
119 // Stash the callbacks so we can call them later.
120 this.activeRequests[id.toString()] = [resolve, reject, method];
121
122 const req = this.buildRequest(id, method, params);
123 const json = this.messagesWrappedInBrackets
124 ? "[" + JSON.stringify(req) + "]\r\n"
125 : JSON.stringify(req) + "\r\n";
126 this.sendMessage(json);
127 });
128 }
129
130 public cancelAllRequests() {
131 // TODO(dantup): Consider/test rejecting all active requests?

Callers

nothing calls this directly

Calls 3

sendMessageMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected