@colyseus/core 0.18.13 → 0.18.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/Room.mjs CHANGED
@@ -1393,9 +1393,11 @@ var Room = class _Room {
1393
1393
  debugAndPrintError(`${this.roomName} (roomId: ${this.roomId}), couldn't decode message: ${buffer}`);
1394
1394
  return;
1395
1395
  }
1396
- if (this.clock.currentTime - (client._lastMessageTime ?? 0) >= 1e3) {
1396
+ const now = this.clock.currentTime;
1397
+ client._lastMessageTime = now;
1398
+ if (now >= (client._messageCountResetsAt ?? 0)) {
1397
1399
  client._numMessagesLastSecond = 0;
1398
- client._lastMessageTime = this.clock.currentTime;
1400
+ client._messageCountResetsAt = now + 1e3;
1399
1401
  } else if ((client._numMessagesLastSecond = (client._numMessagesLastSecond ?? 0) + 1) > this.maxMessagesPerSecond) {
1400
1402
  debugMatchMaking("dropping client - sessionId: '%s' (roomId: %s), too many messages per second", client.sessionId, this.roomId);
1401
1403
  return this.#_forciblyCloseClient(client, CloseCode.WITH_ERROR);