@colyseus/core 0.18.2 → 0.18.4

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.
Files changed (45) hide show
  1. package/build/MatchMaker.cjs +2 -2
  2. package/build/MatchMaker.cjs.map +2 -2
  3. package/build/MatchMaker.d.ts +10 -4
  4. package/build/MatchMaker.mjs +2 -2
  5. package/build/MatchMaker.mjs.map +2 -2
  6. package/build/Room.cjs +11 -3
  7. package/build/Room.cjs.map +2 -2
  8. package/build/Room.d.ts +1 -1
  9. package/build/Room.mjs +11 -3
  10. package/build/Room.mjs.map +2 -2
  11. package/build/RoomMessages.cjs +2 -1
  12. package/build/RoomMessages.cjs.map +2 -2
  13. package/build/RoomMessages.d.ts +3 -1
  14. package/build/RoomMessages.mjs +2 -1
  15. package/build/RoomMessages.mjs.map +2 -2
  16. package/build/router/default_routes.cjs +2 -1
  17. package/build/router/default_routes.cjs.map +2 -2
  18. package/build/router/default_routes.mjs +2 -1
  19. package/build/router/default_routes.mjs.map +2 -2
  20. package/build/router/index.cjs +6 -1
  21. package/build/router/index.cjs.map +2 -2
  22. package/build/router/index.d.ts +1 -1
  23. package/build/router/index.mjs +6 -1
  24. package/build/router/index.mjs.map +2 -2
  25. package/build/router/node.cjs +22 -2
  26. package/build/router/node.cjs.map +2 -2
  27. package/build/router/node.mjs +22 -2
  28. package/build/router/node.mjs.map +2 -2
  29. package/build/utils/Utils.cjs.map +2 -2
  30. package/build/utils/Utils.d.ts +12 -0
  31. package/build/utils/Utils.mjs.map +2 -2
  32. package/build/utils/nanoevents.cjs +4 -1
  33. package/build/utils/nanoevents.cjs.map +2 -2
  34. package/build/utils/nanoevents.d.ts +3 -1
  35. package/build/utils/nanoevents.mjs +4 -1
  36. package/build/utils/nanoevents.mjs.map +2 -2
  37. package/package.json +9 -8
  38. package/src/MatchMaker.ts +33 -12
  39. package/src/Room.ts +23 -4
  40. package/src/RoomMessages.ts +2 -1
  41. package/src/router/default_routes.ts +2 -1
  42. package/src/router/index.ts +16 -1
  43. package/src/router/node.ts +26 -2
  44. package/src/utils/Utils.ts +18 -0
  45. package/src/utils/nanoevents.ts +4 -1
package/build/Room.mjs CHANGED
@@ -1065,7 +1065,7 @@ var Room = class _Room {
1065
1065
  * Allow the specified client to reconnect into the room. Must be used inside `onLeave()` method.
1066
1066
  * If seconds is provided, the reconnection is going to be cancelled after the provided amount of seconds.
1067
1067
  *
1068
- * @param client - The client that is allowed to reconnect into the room.
1068
+ * @param previousClient - The client that is allowed to reconnect into the room.
1069
1069
  * @param seconds - The time in seconds that the client is allowed to reconnect into the room.
1070
1070
  *
1071
1071
  * @returns Deferred<Client> - The differed is a promise like type.
@@ -1332,7 +1332,12 @@ var Room = class _Room {
1332
1332
  #_forciblyCloseClient(client, closeCode, reason) {
1333
1333
  client.ref.removeAllListeners("message");
1334
1334
  client.ref.removeListener("close", client.ref["onleave"]);
1335
- this._onLeave(client, closeCode).then(() => client.leave(closeCode, reason));
1335
+ const ref = client.ref;
1336
+ this._onLeave(client, closeCode).then(() => {
1337
+ if (client.ref === ref) {
1338
+ client.leave(closeCode, reason);
1339
+ }
1340
+ });
1336
1341
  }
1337
1342
  async _onLeave(client, code) {
1338
1343
  const method = code === CloseCode.CONSENTED || client.state === ClientState.RECONNECTING ? this.onLeave : this.onDrop || this.onLeave;
@@ -1353,11 +1358,14 @@ var Room = class _Room {
1353
1358
  this.#_onLeaveConcurrent--;
1354
1359
  }
1355
1360
  }
1361
+ if (client.state === ClientState.RECONNECTED) {
1362
+ return;
1363
+ }
1356
1364
  if (this._reconnections[client.reconnectionToken]) {
1357
1365
  this._reconnections[client.reconnectionToken][1].catch(async () => {
1358
1366
  await this.#_onAfterLeave(client, code, method === this.onDrop);
1359
1367
  });
1360
- } else if (client.state !== ClientState.RECONNECTED) {
1368
+ } else {
1361
1369
  await this.#_onAfterLeave(client, code, method === this.onDrop);
1362
1370
  }
1363
1371
  }