MCPcopy Create free account
hub / github.com/Noumena-Network/code / request

Method request

src/remote/appServer/client.ts:298–316  ·  view source on GitHub ↗
(request: ClientRequest)

Source from the content-addressed store, hash-verified

296 }
297
298 async request<T = JsonRpcResult>(request: ClientRequest): Promise<T> {
299 this.assertOpen()
300 const key = requestIdKey(request.id)
301 if (this.pendingRequests.has(key)) {
302 throw new Error(`duplicate remote app-server request id ${String(request.id)}`)
303 }
304
305 const resultPromise = new Promise<JsonRpcResult>((resolve, reject) => {
306 this.pendingRequests.set(key, { resolve, reject })
307 })
308
309 try {
310 this.sendMessage(request)
311 return (await resultPromise) as T
312 } catch (error) {
313 this.pendingRequests.delete(key)
314 throw error
315 }
316 }
317
318 async notify(notification: ClientNotification): Promise<void> {
319 this.assertOpen()

Callers 2

cancelRequestMethod · 0.45
cancelRequestMethod · 0.45

Calls 6

assertOpenMethod · 0.95
sendMessageMethod · 0.95
requestIdKeyFunction · 0.85
setMethod · 0.80
deleteMethod · 0.80
hasMethod · 0.45

Tested by

no test coverage detected