MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / handleRpc

Function handleRpc

scripts/studio-host-provider.mjs:343–363  ·  view source on GitHub ↗
(config, request)

Source from the content-addressed store, hash-verified

341}
342
343async function handleRpc(config, request) {
344 if (isWebSocketUpgradeRequest(request)) {
345 await completeRpc(config, request.id, {
346 responseBodyBase64: Buffer.from(
347 "Studio provider RPC does not tunnel WebSocket upgrade requests.",
348 ).toString("base64"),
349 responseHeaders: { "content-type": "text/plain; charset=utf-8" },
350 responseStatus: 426,
351 });
352 return;
353 }
354 try {
355 await completeRpc(
356 config,
357 request.id,
358 await proxyLocalRequest(config, request),
359 );
360 } catch (error) {
361 await completeRpc(config, request.id, { error: describeError(error) });
362 }
363}
364
365async function proxyLocalRequest(config, request) {
366 const target = new URL(request.path, `${config.localUrl}/`);

Callers 1

pollRpcFunction · 0.85

Calls 6

completeRpcFunction · 0.85
toStringMethod · 0.80
fromMethod · 0.80
proxyLocalRequestFunction · 0.70
describeErrorFunction · 0.70

Tested by

no test coverage detected