aboutsummaryrefslogtreecommitdiff
path: root/static/src/network.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth@simponic.xyz>2024-09-05 00:15:14 -0700
committerElizabeth Hunt <elizabeth@simponic.xyz>2024-09-05 00:15:14 -0700
commit45726367eee475a7717d7dcad78895de348f0b97 (patch)
tree937abae9cd74d8f99f149cf3c3ee534169c723f8 /static/src/network.ts
parentc39367ac7e163395ae726bd169926004d4d99d67 (diff)
downloadkennel.hatecomputers.club-45726367eee475a7717d7dcad78895de348f0b97.tar.gz
kennel.hatecomputers.club-45726367eee475a7717d7dcad78895de348f0b97.zip
checkpoint; working position updates
Diffstat (limited to 'static/src/network.ts')
-rw-r--r--static/src/network.ts6
1 files changed, 4 insertions, 2 deletions
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 = [];
}