MCPcopy Create free account
hub / github.com/EsperoTech/yaade / messageHandler

Function messageHandler

client/src/utils/websocket.ts:17–35  ·  view source on GitHub ↗
(event: MessageEvent)

Source from the content-addressed store, hash-verified

15 }, 5000);
16
17 const messageHandler = (event: MessageEvent) => {
18 let res;
19 try {
20 res = JSON.parse(event.data);
21 } catch (e) {
22 console.error('messageHandler', e);
23 return;
24 }
25 if (msg?.type === `${msg.type}-result` && res?.err) {
26 cleanup();
27 reject(new Error(res.err || 'Write failed'));
28 } else if (
29 res?.type === `${msg.type}-result` &&
30 res?.result?.metaData?.messageId === msg.metaData?.messageId
31 ) {
32 cleanup();
33 resolve(res.result);
34 }
35 };
36
37 const cleanup = () => {
38 clearTimeout(timeoutId);

Callers

nothing calls this directly

Calls 1

cleanupFunction · 0.85

Tested by

no test coverage detected