mirror of
https://github.com/denoland/deno.git
synced 2024-12-03 17:08:35 -05:00
7966bf14c0
* split ops/worker.rs into ops/worker_host.rs and ops/web_worker.rs * refactor js/workers.ts and factor out js/worker_main.ts - entry point for WebWorker runtime * BREAKING CHANGE: remove support for blob: URL in Worker * BREAKING CHANGE: remove Deno namespace support and noDenoNamespace option in Worker constructor * introduce WebWorker struct which is a stripped down version of cli::Worker
21 lines
506 B
TypeScript
21 lines
506 B
TypeScript
onmessage = function(e): void {
|
|
const { cmdId, action, data } = e.data;
|
|
switch (action) {
|
|
case 0: // Static response
|
|
postMessage({
|
|
cmdId,
|
|
data: "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n"
|
|
});
|
|
break;
|
|
case 1: // Respond with request data
|
|
postMessage({ cmdId, data });
|
|
break;
|
|
case 2: // Ping
|
|
postMessage({ cmdId });
|
|
break;
|
|
case 3: // Close
|
|
postMessage({ cmdId: 3 });
|
|
workerClose();
|
|
break;
|
|
}
|
|
};
|