From 078bd4f8f1eb2151a8725acfe1605ee3de79cc02 Mon Sep 17 00:00:00 2001 From: Isaac Thoman <49598528+IsaacThoman@users.noreply.github.com> Date: Thu, 2 Jan 2025 21:29:34 -0500 Subject: [PATCH] perf: make playerData emits volatile --- src/client/core/Networking.ts | 2 +- src/server/GameEngine.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/core/Networking.ts b/src/client/core/Networking.ts index fbb2be1..39bdcc3 100644 --- a/src/client/core/Networking.ts +++ b/src/client/core/Networking.ts @@ -137,7 +137,7 @@ export class Networking { if (this.playersAreEqualEnough(this.localPlayer, this.lastUploadedLocalPlayer) && currentTime - this.lastUploadTime < 4) return; - this.socket.emit('playerData', this.localPlayer); + this.socket.volatile.emit('playerData', this.localPlayer); this.lastUploadedLocalPlayer = { position: this.localPlayer.position.clone(), quaternion: this.localPlayer.quaternion.clone(), diff --git a/src/server/GameEngine.ts b/src/server/GameEngine.ts index 948b737..9ceb0dc 100644 --- a/src/server/GameEngine.ts +++ b/src/server/GameEngine.ts @@ -38,7 +38,7 @@ export class GameEngine { // Emit player data if there are updates or enough time has passed if (this.playerUpdateSinceLastEmit || currentTime - this.lastPlayerTickTimestamp > 1 / config.server.tickRate) { try { - this.io.emit('remotePlayerData', this.playerManager.getAllPlayers()); + this.io.volatile.emit('remotePlayerData', this.playerManager.getAllPlayers()); this.playerUpdateSinceLastEmit = false; this.lastPlayerTickTimestamp = currentTime; } catch (err) {