stop clock if all stopped

This commit is contained in:
Jade (Rose) Rowland 2024-03-10 14:35:43 -04:00
parent 30a5176090
commit 112ca1875a
2 changed files with 17 additions and 9 deletions

View file

@ -17,6 +17,7 @@ export class NeoCyclist {
this.onToggle = onToggle;
this.latency = 0.1; // fixed trigger time offset
this.cycle = 0;
this.id = Math.round(Date.now() * Math.random());
this.worker = new SharedWorker(new URL('./clockworker.js', import.meta.url));
this.worker.port.start();
@ -107,7 +108,7 @@ export class NeoCyclist {
};
}
sendMessage(type, payload) {
this.worker.port.postMessage({ type, payload });
this.worker.port.postMessage({ type, payload, id: this.id });
}
now() {