mirror of
https://codeberg.org/vlw/monkeydo.git
synced 2025-09-13 15:53:40 +02:00
30 lines
No EOL
717 B
JavaScript
30 lines
No EOL
717 B
JavaScript
// Spawn a dedicated worker for scheduling events from manifest
|
|
|
|
export default class MonkeyWorker {
|
|
constructor() {
|
|
// Get location of this file
|
|
this.ready = false;
|
|
let location = new URL(import.meta.url);
|
|
location = location.pathname.replace("MonkeyWorker.mjs","");
|
|
|
|
// Spawn worker from file relative to this file
|
|
this.worker = new Worker(location + "Sequencer.js");
|
|
this.worker.addEventListener("message",message => this.message(message));
|
|
}
|
|
|
|
play() {
|
|
this.worker.postMessage(["PLAYSTATE",true]);
|
|
}
|
|
|
|
pause() {
|
|
this.worker.postMessage(["PLAYSTATE",false]);
|
|
}
|
|
|
|
giveManifest() {
|
|
this.worker.postMessage(["GIVE_MANIFEST",this.manifest]);
|
|
}
|
|
|
|
message(message) {
|
|
console.log(message);
|
|
}
|
|
} |