Skip to content

Instantly share code, notes, and snippets.

Created Aug 12, 2021
What would you like to do?
const prefix = "pmrpc."
if (!data.startsWith(prefix)) throw new Error(`got weird messsage ${JSON.stringify(data)}`);
// trim off 'pmrpc.'
const json = data.slice(prefix.length);
// extract the request JSON
const rq = JSON.parse(json);
const { method, jsonrpc, params, id } = rq;
// if we get a config, just return our pre-prepared response
if (method == "config") return frame.postMessage(`${prefix}${JSON.stringify({
...config_resp, jsonrpc, id
})}`, "*");
// for everything else just tell the child it went OK
jsonrpc, id, result: true
})}`, "*");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment