Skip to content

Commit

Permalink
perf: make playerData emits volatile
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacThoman committed Jan 3, 2025
1 parent 124da15 commit 078bd4f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/client/core/Networking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/server/GameEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 078bd4f

Please sign in to comment.