Skip to content

Commit

Permalink
fix: stringify message once
Browse files Browse the repository at this point in the history
  • Loading branch information
cyperdark committed Feb 23, 2024
1 parent 7c03eb8 commit c512928
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/server/utils/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,15 @@ export class Websocket {
}

if (this.clients.size > 0) {
this.clients.forEach((value, key) => {
try {
value.send(
JSON.stringify(
osuInstances[0][this.stateFunctionName](
this.instanceManager
)
)
);
} catch (error) {}
});
try {
const message = JSON.stringify(
osuInstances[0][this.stateFunctionName](
this.instanceManager
)
);

this.clients.forEach((client, key) => client.send(message));
} catch (error) {}
}

setTimeout(this.loop, config[this.pollRateFieldName]);
Expand Down

0 comments on commit c512928

Please sign in to comment.