MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / handleMessage

Method handleMessage

projects/runtime-client/src/client.ts:226–253  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

224 }
225
226 private handleMessage(raw: string): void {
227 let message: unknown
228 try {
229 message = JSON.parse(raw)
230 } catch {
231 return
232 }
233
234 const response = validateRuntimeResponse(message)
235 if (response.ok) {
236 const pending = this.pending.get(response.value.id)
237 if (!pending) return
238 this.pending.delete(response.value.id)
239 if (response.value.error) {
240 pending.reject(new RuntimeClientError(response.value.error.code, response.value.error.message, response.value.error.data))
241 } else {
242 pending.resolve(response.value.result)
243 }
244 return
245 }
246
247 if (isRuntimeNotification(message)) {
248 if (typeof message.cursor === "string") this.lastCursor = message.cursor
249 for (const listener of this.listeners) {
250 listener(message)
251 }
252 }
253 }
254}
255
256export class RuntimeLocalClient {

Callers 2

openOnceMethod · 0.95
attachSocketFunction · 0.45

Calls 6

validateRuntimeResponseFunction · 0.90
isRuntimeNotificationFunction · 0.90
rejectMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65
listenerFunction · 0.50

Tested by

no test coverage detected