blob: 3f557a4fb2fa46bf13d1a2fab7104dde6ed638ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
onmessage = function (pingEvt) {
if (pingEvt.data == "ping") {
let { port1, port2 } = new MessageChannel();
port2.onmessage = helloEvt => {
if (helloEvt.data == "hello") {
helloEvt.ports[0].postMessage("goodbye");
}
};
pingEvt.ports[0].postMessage("pong", [port1]);
}
};
|