@colyseus/core 0.18.9 → 0.18.11

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.cjs CHANGED
@@ -474,11 +474,7 @@ var Room = class _Room {
474
474
  hasReservedSeat(sessionId, reconnectionToken) {
475
475
  const reservedSeat = this._reservedSeats[sessionId];
476
476
  if (reservedSeat) {
477
- return (
478
- // not consumed
479
- reservedSeat[2] === false || // reconnection is allowed and the reconnection token is valid.
480
- reservedSeat[3] && this._reconnections[reconnectionToken]?.[0] === sessionId
481
- );
477
+ return reservedSeat[3] ? this._reconnections[reconnectionToken]?.[0] === sessionId : reservedSeat[2] === false;
482
478
  } else if (typeof reconnectionToken === "string") {
483
479
  return this.clients.get(sessionId)?.reconnectionToken === reconnectionToken;
484
480
  }
@@ -1423,10 +1419,10 @@ var Room = class _Room {
1423
1419
  (0, import_Debug.debugAndPrintError)(`${this.roomName} (roomId: ${this.roomId}), couldn't decode message: ${buffer}`);
1424
1420
  return;
1425
1421
  }
1426
- if (this.clock.currentTime - client._lastMessageTime >= 1e3) {
1422
+ if (this.clock.currentTime - (client._lastMessageTime ?? 0) >= 1e3) {
1427
1423
  client._numMessagesLastSecond = 0;
1428
1424
  client._lastMessageTime = this.clock.currentTime;
1429
- } else if (++client._numMessagesLastSecond > this.maxMessagesPerSecond) {
1425
+ } else if ((client._numMessagesLastSecond = (client._numMessagesLastSecond ?? 0) + 1) > this.maxMessagesPerSecond) {
1430
1426
  (0, import_Debug.debugMatchMaking)("dropping client - sessionId: '%s' (roomId: %s), too many messages per second", client.sessionId, this.roomId);
1431
1427
  return this.#_forciblyCloseClient(client, import_shared_types.CloseCode.WITH_ERROR);
1432
1428
  }