1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
"use strict"; self.onconnect = function (event) { event.ports[0].onmessage = function (e) { switch (e.data) { case "close": close(); break; case "close_loop": close(); // Let's loop forever. while (1) {} break; } }; };