keep tilts synced

This commit is contained in:
Gavin McDonald
2025-07-01 14:35:32 -04:00
parent 6b3ab9a54e
commit f61ca0d0a1
4 changed files with 29 additions and 21 deletions

View File

@@ -21,7 +21,6 @@ const timedReleases = {};
app.prepare().then(() => {
const httpServer = createServer(handler);
const io = new SocketIOServer(httpServer);
const broadcast = (event: string, gameUpdate: GameUpdate) => {
@@ -32,9 +31,9 @@ app.prepare().then(() => {
const timedRelease = (event: string, gameUpdate: GameUpdate, threshold: number) => {
const now = Date.now();
const lastEvent = timedReleases[event];
clearTimeout(lastEvent?.to);
if (lastEvent?.embargo >= now) {
clearTimeout(lastEvent.to);
const embargo = lastEvent.embargo - now;
const to = setTimeout(() => {