@colyseus/core 0.18.16 → 0.18.17

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 (36) hide show
  1. package/build/MatchMaker.cjs +93 -10
  2. package/build/MatchMaker.cjs.map +3 -3
  3. package/build/MatchMaker.d.ts +20 -1
  4. package/build/MatchMaker.mjs +93 -11
  5. package/build/MatchMaker.mjs.map +3 -3
  6. package/build/Room.cjs.map +2 -2
  7. package/build/Room.mjs.map +2 -2
  8. package/build/matchmaker/LocalDriver/LocalDriver.cjs +14 -1
  9. package/build/matchmaker/LocalDriver/LocalDriver.cjs.map +2 -2
  10. package/build/matchmaker/LocalDriver/LocalDriver.d.ts +2 -0
  11. package/build/matchmaker/LocalDriver/LocalDriver.mjs +14 -1
  12. package/build/matchmaker/LocalDriver/LocalDriver.mjs.map +2 -2
  13. package/build/matchmaker/driver.cjs.map +1 -1
  14. package/build/matchmaker/driver.d.ts +11 -0
  15. package/build/matchmaker/driver.mjs.map +1 -1
  16. package/build/presence/LocalPresence.cjs +2 -0
  17. package/build/presence/LocalPresence.cjs.map +2 -2
  18. package/build/presence/LocalPresence.mjs +2 -0
  19. package/build/presence/LocalPresence.mjs.map +2 -2
  20. package/build/utils/DevMode.cjs +3 -0
  21. package/build/utils/DevMode.cjs.map +2 -2
  22. package/build/utils/DevMode.mjs +4 -1
  23. package/build/utils/DevMode.mjs.map +2 -2
  24. package/build/utils/Utils.cjs +6 -0
  25. package/build/utils/Utils.cjs.map +2 -2
  26. package/build/utils/Utils.d.ts +2 -0
  27. package/build/utils/Utils.mjs +4 -0
  28. package/build/utils/Utils.mjs.map +2 -2
  29. package/package.json +4 -4
  30. package/src/MatchMaker.ts +174 -16
  31. package/src/Room.ts +2 -1
  32. package/src/matchmaker/LocalDriver/LocalDriver.ts +15 -7
  33. package/src/matchmaker/driver.ts +12 -0
  34. package/src/presence/LocalPresence.ts +2 -0
  35. package/src/utils/DevMode.ts +4 -1
  36. package/src/utils/Utils.ts +6 -0
@@ -3,7 +3,7 @@ import path from 'path';
3
3
  import { type Schema, MapSchema, ArraySchema, SetSchema, CollectionSchema, $childType, $changes } from '@colyseus/schema';
4
4
  import { logger } from '../Logger.ts';
5
5
  import { debugAndPrintError, debugDevMode } from '../Debug.ts';
6
- import { getLocalRoomById, handleCreateRoom, presence, remoteRoomCall } from '../MatchMaker.ts';
6
+ import { getLocalRoomById, handleCreateRoom, MatchMakerState, presence, remoteRoomCall, state } from '../MatchMaker.ts';
7
7
  import type { Room } from '../Room.ts';
8
8
 
9
9
  const DEVMODE_CACHE_FILE_PATH = path.resolve(".devmode.json");
@@ -49,6 +49,9 @@ export async function reloadFromCache() {
49
49
  recreatedRoom = getLocalRoomById(recreatedRoomListing.roomId);
50
50
 
51
51
  } catch (e: any) {
52
+ // shutdown interrupted the restore: keep the remaining entries for the next boot
53
+ if (state === MatchMakerState.SHUTTING_DOWN) { break; }
54
+
52
55
  // unrestorable entry (e.g. room type renamed/removed) — drop it
53
56
  // instead of wedging the boot
54
57
  debugAndPrintError(`❌ couldn't restore room '${roomId}':\n${e.stack}`);
@@ -44,6 +44,12 @@ export type RemoteRoomCallReturn<
44
44
  export const REMOTE_ROOM_SHORT_TIMEOUT = Number(process.env.COLYSEUS_PRESENCE_SHORT_TIMEOUT || 2000);
45
45
  export const MAX_CONCURRENT_CREATE_ROOM_WAIT_TIME = Number(process.env.COLYSEUS_MAX_CONCURRENT_CREATE_ROOM_WAIT_TIME || 0.5);
46
46
 
47
+ // a peer that removes this process's room listings leaves a receipt. this
48
+ // process looks for it every INTERVAL (ms) and restores them. the TTL (seconds)
49
+ // only bounds what dead processes leave behind.
50
+ export const SWEPT_CHECK_INTERVAL = Number(process.env.COLYSEUS_SWEPT_CHECK_INTERVAL || 5000);
51
+ export const SWEPT_RECEIPT_TTL = Number(process.env.COLYSEUS_SWEPT_RECEIPT_TTL || 600);
52
+
47
53
  /**
48
54
  * The well-known `Symbol.metadata` (TC39 decorator metadata), falling back to the
49
55
  * registered symbol on runtimes that don't expose it globally yet. `@colyseus/schema`