From 45726367eee475a7717d7dcad78895de348f0b97 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Thu, 5 Sep 2024 00:15:14 -0700 Subject: checkpoint; working position updates --- static/src/network.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'static/src/network.ts') diff --git a/static/src/network.ts b/static/src/network.ts index f707148..fac96df 100644 --- a/static/src/network.ts +++ b/static/src/network.ts @@ -66,8 +66,7 @@ export class WebSocketEventQueue implements EventQueue { private listen_to(websocket: WebSocket) { websocket.onmessage = ({ data }) => { - const [event_type, event_data] = JSON.parse(data); - this.queue.push({ event_type, data: event_data } as Event); + this.queue = this.queue.concat(JSON.parse(data)); }; } } @@ -84,6 +83,9 @@ export class WebsocketEventPublisher implements EventPublisher { } public publish() { + if (this.queue.length === 0) { + return; + } this.websocket.send(JSON.stringify(this.queue)); this.queue = []; } -- cgit v1.3