MCPcopy
hub / github.com/RedPlanetHQ/core / send

Method send

apps/webapp/app/components/browser/cdp-client.ts:102–116  ·  view source on GitHub ↗
(
    method: string,
    params: Record<string, unknown> = {},
    sessionId?: string,
  )

Source from the content-addressed store, hash-verified

100 }
101
102 send<T = unknown>(
103 method: string,
104 params: Record<string, unknown> = {},
105 sessionId?: string,
106 ): Promise<T> {
107 const id = this.nextId++;
108 const frame = JSON.stringify({ id, method, params, sessionId });
109 return new Promise<T>((resolve, reject) => {
110 this.pending.set(id, (msg) => {
111 if (msg.error) reject(new Error(msg.error.message));
112 else resolve(msg.result as T);
113 });
114 this.ws.send(frame);
115 });
116 }
117
118 on(sessionId: string, listener: CdpListener): () => void {
119 let set = this.listeners.get(sessionId);

Callers 1

useCdpScreencastFunction · 0.95

Calls 2

sendMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected