MCPcopy Create free account
hub / github.com/code100x/mobile-magic / constructor

Method constructor

mobile-magic/apps/worker/ws.ts:8–24  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

6 private callbacks: Map<string, (data: VscodeMessagePayload) => void>;
7
8 private constructor(url: string) {
9 this.ws = new WebSocket(url);
10 this.callbacks = new Map();
11 this.ws.onmessage = (event) => {
12 const { callbackId, ...data } = JSON.parse(event.data);
13 const callback = this.callbacks.get(callbackId);
14 if (callback) {
15 callback(data);
16 }
17 };
18
19 this.ws.onopen = () => {
20 this.send(JSON.stringify({
21 event: "api_subscribe",
22 }));
23 }
24 }
25
26 static getInstance() {
27 if (!RelayWebsocket.instance) {

Callers

nothing calls this directly

Calls 2

sendMethod · 0.95
parseMethod · 0.80

Tested by

no test coverage detected