@colyseus/core 0.16.0-preview.9 → 0.16.1
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/README.md +5 -5
- package/build/Debug.js +6 -2
- package/build/Debug.js.map +2 -2
- package/build/Debug.mjs +11 -10
- package/build/Debug.mjs.map +2 -2
- package/build/IPC.d.ts +1 -1
- package/build/IPC.js +3 -3
- package/build/IPC.js.map +2 -2
- package/build/IPC.mjs +4 -3
- package/build/IPC.mjs.map +2 -2
- package/build/Logger.mjs +4 -3
- package/build/Logger.mjs.map +1 -1
- package/build/MatchMaker.d.ts +35 -30
- package/build/MatchMaker.js +150 -100
- package/build/MatchMaker.js.map +2 -2
- package/build/MatchMaker.mjs +154 -107
- package/build/MatchMaker.mjs.map +2 -2
- package/build/Protocol.d.ts +3 -4
- package/build/Protocol.js +33 -19
- package/build/Protocol.js.map +2 -2
- package/build/Protocol.mjs +36 -21
- package/build/Protocol.mjs.map +2 -2
- package/build/Room.d.ts +64 -40
- package/build/Room.js +408 -151
- package/build/Room.js.map +2 -2
- package/build/Room.mjs +412 -158
- package/build/Room.mjs.map +2 -2
- package/build/Server.d.ts +8 -7
- package/build/Server.js +51 -18
- package/build/Server.js.map +2 -2
- package/build/Server.mjs +51 -21
- package/build/Server.mjs.map +3 -3
- package/build/Stats.d.ts +2 -0
- package/build/Stats.js +38 -3
- package/build/Stats.js.map +2 -2
- package/build/Stats.mjs +30 -6
- package/build/Stats.mjs.map +2 -2
- package/build/Transport.d.ts +8 -7
- package/build/Transport.js +1 -1
- package/build/Transport.js.map +2 -2
- package/build/Transport.mjs +6 -5
- package/build/Transport.mjs.map +2 -2
- package/build/discovery/index.d.ts +1 -1
- package/build/discovery/index.js.map +2 -2
- package/build/discovery/index.mjs +3 -2
- package/build/discovery/index.mjs.map +2 -2
- package/build/errors/RoomExceptions.d.ts +39 -0
- package/build/errors/RoomExceptions.js +100 -0
- package/build/errors/RoomExceptions.js.map +7 -0
- package/build/errors/RoomExceptions.mjs +71 -0
- package/build/errors/RoomExceptions.mjs.map +7 -0
- package/build/errors/SeatReservationError.mjs +3 -2
- package/build/errors/SeatReservationError.mjs.map +1 -1
- package/build/errors/ServerError.js +1 -1
- package/build/errors/ServerError.js.map +1 -1
- package/build/errors/ServerError.mjs +5 -4
- package/build/errors/ServerError.mjs.map +2 -2
- package/build/index.d.ts +21 -19
- package/build/index.js +45 -20
- package/build/index.js.map +2 -2
- package/build/index.mjs +39 -19
- package/build/index.mjs.map +2 -2
- package/build/matchmaker/Lobby.d.ts +3 -3
- package/build/matchmaker/Lobby.js +6 -3
- package/build/matchmaker/Lobby.js.map +2 -2
- package/build/matchmaker/Lobby.mjs +4 -4
- package/build/matchmaker/Lobby.mjs.map +2 -2
- package/build/matchmaker/RegisteredHandler.d.ts +6 -7
- package/build/matchmaker/RegisteredHandler.js +7 -10
- package/build/matchmaker/RegisteredHandler.js.map +2 -2
- package/build/matchmaker/RegisteredHandler.mjs +11 -13
- package/build/matchmaker/RegisteredHandler.mjs.map +2 -2
- package/build/matchmaker/controller.d.ts +4 -5
- package/build/matchmaker/controller.js +22 -15
- package/build/matchmaker/controller.js.map +2 -2
- package/build/matchmaker/controller.mjs +19 -13
- package/build/matchmaker/controller.mjs.map +2 -2
- package/build/matchmaker/driver/api.d.ts +104 -0
- package/build/matchmaker/driver/api.js +29 -0
- package/build/matchmaker/driver/api.js.map +7 -0
- package/build/matchmaker/driver/api.mjs +7 -0
- package/build/matchmaker/driver/api.mjs.map +7 -0
- package/build/matchmaker/driver/index.d.ts +2 -2
- package/build/matchmaker/driver/index.js +2 -2
- package/build/matchmaker/driver/index.js.map +2 -2
- package/build/matchmaker/driver/index.mjs +5 -4
- package/build/matchmaker/driver/index.mjs.map +2 -2
- package/build/matchmaker/driver/local/LocalDriver.d.ts +13 -0
- package/build/matchmaker/driver/local/LocalDriver.js +65 -0
- package/build/matchmaker/driver/local/LocalDriver.js.map +7 -0
- package/build/matchmaker/driver/local/LocalDriver.mjs +43 -0
- package/build/matchmaker/driver/local/LocalDriver.mjs.map +7 -0
- package/build/matchmaker/driver/local/Query.d.ts +9 -0
- package/build/matchmaker/driver/local/Query.js +78 -0
- package/build/matchmaker/driver/local/Query.js.map +7 -0
- package/build/matchmaker/driver/local/Query.mjs +56 -0
- package/build/matchmaker/driver/local/Query.mjs.map +7 -0
- package/build/matchmaker/driver/local/RoomData.d.ts +19 -0
- package/build/matchmaker/driver/local/RoomData.js +79 -0
- package/build/matchmaker/driver/local/RoomData.js.map +7 -0
- package/build/matchmaker/driver/local/RoomData.mjs +57 -0
- package/build/matchmaker/driver/local/RoomData.mjs.map +7 -0
- package/build/presence/LocalPresence.d.ts +10 -6
- package/build/presence/LocalPresence.js +85 -24
- package/build/presence/LocalPresence.js.map +3 -3
- package/build/presence/LocalPresence.mjs +85 -27
- package/build/presence/LocalPresence.mjs.map +3 -3
- package/build/presence/Presence.d.ts +38 -2
- package/build/presence/Presence.js.map +1 -1
- package/build/rooms/LobbyRoom.d.ts +6 -6
- package/build/rooms/LobbyRoom.js +8 -3
- package/build/rooms/LobbyRoom.js.map +2 -2
- package/build/rooms/LobbyRoom.mjs +7 -5
- package/build/rooms/LobbyRoom.mjs.map +2 -2
- package/build/rooms/RelayRoom.d.ts +3 -3
- package/build/rooms/RelayRoom.js +3 -1
- package/build/rooms/RelayRoom.js.map +2 -2
- package/build/rooms/RelayRoom.mjs +10 -7
- package/build/rooms/RelayRoom.mjs.map +2 -2
- package/build/serializer/NoneSerializer.d.ts +2 -2
- package/build/serializer/NoneSerializer.js.map +1 -1
- package/build/serializer/NoneSerializer.mjs +3 -2
- package/build/serializer/NoneSerializer.mjs.map +2 -2
- package/build/serializer/SchemaSerializer.d.ts +16 -15
- package/build/serializer/SchemaSerializer.js +12 -10
- package/build/serializer/SchemaSerializer.js.map +2 -2
- package/build/serializer/SchemaSerializer.mjs +16 -13
- package/build/serializer/SchemaSerializer.mjs.map +2 -2
- package/build/serializer/SchemaSerializerDebug.d.ts +7 -0
- package/build/serializer/SchemaSerializerDebug.js +0 -0
- package/build/serializer/SchemaSerializerDebug.js.map +7 -0
- package/build/serializer/SchemaSerializerDebug.mjs +0 -0
- package/build/serializer/SchemaSerializerDebug.mjs.map +7 -0
- package/build/serializer/Serializer.d.ts +1 -2
- package/build/serializer/Serializer.js.map +1 -1
- package/build/utils/DevMode.d.ts +2 -2
- package/build/utils/DevMode.js +8 -4
- package/build/utils/DevMode.js.map +2 -2
- package/build/utils/DevMode.mjs +7 -6
- package/build/utils/DevMode.mjs.map +2 -2
- package/build/utils/Utils.d.ts +8 -3
- package/build/utils/Utils.js +41 -17
- package/build/utils/Utils.js.map +2 -2
- package/build/utils/Utils.mjs +40 -21
- package/build/utils/Utils.mjs.map +2 -2
- package/package.json +17 -6
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/matchmaker/driver/api.ts"],
|
|
4
|
+
"sourcesContent": ["export interface SortOptions {\n [fieldName: string]: 1 | -1 | 'asc' | 'desc' | 'ascending' | 'descending';\n}\n\nexport function getLockId(filterOptions: any) {\n return Object.keys(filterOptions).map((key) => `${key}:${filterOptions[key]}`).join(\"-\");\n}\n\nexport interface IRoomCache {\n /**\n * Unique identifier for the room.\n */\n roomId: string;\n\n /**\n * Number of clients connected to this room.\n */\n clients: number;\n\n /**\n * Maximum number of clients allowed to join the room.\n */\n maxClients: number;\n\n /**\n * Indicates if the room is locked (i.e. join requests are rejected).\n */\n locked: boolean;\n\n /**\n * Indicates if the room is private\n * Private rooms can't be joined via `join()` or `joinOrCreate()`.\n */\n private: boolean;\n\n /**\n * Room name.\n */\n name: string;\n\n /**\n * Public address of the server.\n */\n publicAddress?: string;\n\n /**\n * Process id where the room is running.\n */\n processId: string;\n\n /**\n * Do not show this room in lobby listing.\n */\n unlisted: boolean;\n\n /**\n * Metadata associated with the room.\n */\n metadata: any;\n\n /**\n * Additional custom properties\n */\n [property: string]: any;\n}\n\nexport interface RoomCache<Metadata= any> extends IRoomCache {\n metadata: Metadata;\n\n updateOne(operations: any);\n save();\n remove();\n}\n\nexport interface MatchMakerDriver {\n /**\n * Initialize a room cache which contains CRUD operations for room listings.\n *\n * @param initialValues - Predefined room properties.\n *\n * @returns RoomData - New room cache.\n */\n createInstance(initialValues: Partial<IRoomCache>): RoomCache;\n\n /**\n * Check if a room exists in room cache.\n *\n * @param roomId - The room id.\n *\n * @returns Promise<boolean> | boolean - A promise or a boolean value indicating if the room exists.\n */\n has(roomId: string): Promise<boolean> | boolean;\n\n /**\n * Query rooms in room cache for given conditions.\n *\n * @param conditions - Filtering conditions.\n *\n * @returns Promise<IRoomCache[]> | IRoomCache[] - A promise or an object contaning room metadata list.\n */\n query(conditions: Partial<IRoomCache>, sortOptions?: SortOptions,): Promise<IRoomCache[]> | IRoomCache[];\n\n /**\n * Clean up rooms in room cache by process id.\n * @param processId - The process id.\n */\n cleanup?(processId: string): Promise<void>;\n\n /**\n * Query for a room in room cache for given conditions.\n *\n * @param conditions - Filtering conditions.\n *\n * @returns `IRoomCache` - An object contaning filtered room metadata.\n */\n findOne(conditions: Partial<IRoomCache>, sortOptions?: SortOptions): Promise<RoomCache>;\n\n /**\n * Empty the room cache.\n */\n clear(): void;\n\n /**\n * Dispose the connection of the room cache medium.\n */\n shutdown(): void;\n\n // /**\n // *\n // */\n // lock(): void;\n\n // /**\n // *\n // */\n // releaseLock(): void;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,SAAS,UAAU,eAAoB;AAC5C,SAAO,OAAO,KAAK,aAAa,EAAE,IAAI,CAAC,QAAQ,GAAG,GAAG,IAAI,cAAc,GAAG,CAAC,EAAE,EAAE,KAAK,GAAG;AACzF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/matchmaker/driver/api.ts"],
|
|
4
|
+
"sourcesContent": ["export interface SortOptions {\n [fieldName: string]: 1 | -1 | 'asc' | 'desc' | 'ascending' | 'descending';\n}\n\nexport function getLockId(filterOptions: any) {\n return Object.keys(filterOptions).map((key) => `${key}:${filterOptions[key]}`).join(\"-\");\n}\n\nexport interface IRoomCache {\n /**\n * Unique identifier for the room.\n */\n roomId: string;\n\n /**\n * Number of clients connected to this room.\n */\n clients: number;\n\n /**\n * Maximum number of clients allowed to join the room.\n */\n maxClients: number;\n\n /**\n * Indicates if the room is locked (i.e. join requests are rejected).\n */\n locked: boolean;\n\n /**\n * Indicates if the room is private\n * Private rooms can't be joined via `join()` or `joinOrCreate()`.\n */\n private: boolean;\n\n /**\n * Room name.\n */\n name: string;\n\n /**\n * Public address of the server.\n */\n publicAddress?: string;\n\n /**\n * Process id where the room is running.\n */\n processId: string;\n\n /**\n * Do not show this room in lobby listing.\n */\n unlisted: boolean;\n\n /**\n * Metadata associated with the room.\n */\n metadata: any;\n\n /**\n * Additional custom properties\n */\n [property: string]: any;\n}\n\nexport interface RoomCache<Metadata= any> extends IRoomCache {\n metadata: Metadata;\n\n updateOne(operations: any);\n save();\n remove();\n}\n\nexport interface MatchMakerDriver {\n /**\n * Initialize a room cache which contains CRUD operations for room listings.\n *\n * @param initialValues - Predefined room properties.\n *\n * @returns RoomData - New room cache.\n */\n createInstance(initialValues: Partial<IRoomCache>): RoomCache;\n\n /**\n * Check if a room exists in room cache.\n *\n * @param roomId - The room id.\n *\n * @returns Promise<boolean> | boolean - A promise or a boolean value indicating if the room exists.\n */\n has(roomId: string): Promise<boolean> | boolean;\n\n /**\n * Query rooms in room cache for given conditions.\n *\n * @param conditions - Filtering conditions.\n *\n * @returns Promise<IRoomCache[]> | IRoomCache[] - A promise or an object contaning room metadata list.\n */\n query(conditions: Partial<IRoomCache>, sortOptions?: SortOptions,): Promise<IRoomCache[]> | IRoomCache[];\n\n /**\n * Clean up rooms in room cache by process id.\n * @param processId - The process id.\n */\n cleanup?(processId: string): Promise<void>;\n\n /**\n * Query for a room in room cache for given conditions.\n *\n * @param conditions - Filtering conditions.\n *\n * @returns `IRoomCache` - An object contaning filtered room metadata.\n */\n findOne(conditions: Partial<IRoomCache>, sortOptions?: SortOptions): Promise<RoomCache>;\n\n /**\n * Empty the room cache.\n */\n clear(): void;\n\n /**\n * Dispose the connection of the room cache medium.\n */\n shutdown(): void;\n\n // /**\n // *\n // */\n // lock(): void;\n\n // /**\n // *\n // */\n // releaseLock(): void;\n}\n"],
|
|
5
|
+
"mappings": ";AAIO,SAAS,UAAU,eAAoB;AAC5C,SAAO,OAAO,KAAK,aAAa,EAAE,IAAI,CAAC,QAAQ,GAAG,GAAG,IAAI,cAAc,GAAG,CAAC,EAAE,EAAE,KAAK,GAAG;AACzF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -3,11 +3,11 @@ export type { IRoomListingData, SortOptions, RoomListingData, QueryHelpers, Matc
|
|
|
3
3
|
import { RoomCache } from './RoomData';
|
|
4
4
|
export declare class LocalDriver implements MatchMakerDriver {
|
|
5
5
|
rooms: RoomCache[];
|
|
6
|
-
createInstance(initialValues?: any):
|
|
6
|
+
createInstance(initialValues?: any): any;
|
|
7
7
|
has(roomId: string): boolean;
|
|
8
8
|
find(conditions: Partial<IRoomListingData>): RoomCache[];
|
|
9
9
|
cleanup(processId: string): Promise<void>;
|
|
10
|
-
findOne(conditions: Partial<IRoomListingData>): QueryHelpers<RoomListingData
|
|
10
|
+
findOne(conditions: Partial<IRoomListingData>): QueryHelpers<RoomListingData>;
|
|
11
11
|
clear(): void;
|
|
12
12
|
shutdown(): void;
|
|
13
13
|
}
|
|
@@ -20,7 +20,7 @@ __export(driver_exports, {
|
|
|
20
20
|
LocalDriver: () => LocalDriver
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(driver_exports);
|
|
23
|
-
var
|
|
23
|
+
var import_Debug = require("../../Debug");
|
|
24
24
|
var import_Query = require("./Query");
|
|
25
25
|
var import_RoomData = require("./RoomData");
|
|
26
26
|
class LocalDriver {
|
|
@@ -45,7 +45,7 @@ class LocalDriver {
|
|
|
45
45
|
}
|
|
46
46
|
cleanup(processId) {
|
|
47
47
|
const cachedRooms = this.find({ processId });
|
|
48
|
-
|
|
48
|
+
(0, import_Debug.debugMatchMaking)("removing stale rooms by processId %s (%s rooms found)", processId, cachedRooms.length);
|
|
49
49
|
cachedRooms.forEach((room) => room.remove());
|
|
50
50
|
return Promise.resolve();
|
|
51
51
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/matchmaker/driver/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { logger } from \"../../Logger\";\nimport { IRoomListingData, SortOptions, RoomListingData, QueryHelpers, MatchMakerDriver } from \"./interfaces\";\n\n// re-export\nexport type { IRoomListingData, SortOptions, RoomListingData, QueryHelpers, MatchMakerDriver };\n\nimport { Query } from './Query';\nimport { RoomCache } from './RoomData';\n\nexport class LocalDriver implements MatchMakerDriver {\n public rooms: RoomCache[] = [];\n\n public createInstance(initialValues: any = {}) {\n return new RoomCache(initialValues, this.rooms);\n }\n\n public has(roomId: string) {\n return this.rooms.some((room) => room.roomId === roomId);\n }\n\n public find(conditions: Partial<IRoomListingData>) {\n return this.rooms.filter(((room) => {\n for (const field in conditions) {\n if (\n conditions.hasOwnProperty(field) &&\n room[field] !== conditions[field]\n ) {\n return false;\n }\n }\n return true;\n }));\n }\n\n public cleanup(processId: string) {\n const cachedRooms = this.find({ processId });\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { debugMatchMaking } from \"../../Debug\";\nimport { logger } from \"../../Logger\";\nimport { IRoomListingData, SortOptions, RoomListingData, QueryHelpers, MatchMakerDriver } from \"./interfaces\";\n\n// re-export\nexport type { IRoomListingData, SortOptions, RoomListingData, QueryHelpers, MatchMakerDriver };\n\nimport { Query } from './Query';\nimport { RoomCache } from './RoomData';\n\nexport class LocalDriver implements MatchMakerDriver {\n public rooms: RoomCache[] = [];\n\n public createInstance(initialValues: any = {}) {\n return new RoomCache(initialValues, this.rooms);\n }\n\n public has(roomId: string) {\n return this.rooms.some((room) => room.roomId === roomId);\n }\n\n public find(conditions: Partial<IRoomListingData>) {\n return this.rooms.filter(((room) => {\n for (const field in conditions) {\n if (\n conditions.hasOwnProperty(field) &&\n room[field] !== conditions[field]\n ) {\n return false;\n }\n }\n return true;\n }));\n }\n\n public cleanup(processId: string) {\n const cachedRooms = this.find({ processId });\n debugMatchMaking(\"removing stale rooms by processId %s (%s rooms found)\", processId, cachedRooms.length);\n\n cachedRooms.forEach((room) => room.remove());\n return Promise.resolve();\n }\n\n public findOne(conditions: Partial<IRoomListingData>) {\n return new Query<RoomListingData>(this.rooms, conditions) as any as QueryHelpers<RoomListingData>;\n }\n\n public clear() {\n this.rooms = [];\n }\n\n public shutdown() {\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AAOjC,mBAAsB;AACtB,sBAA0B;AAEnB,MAAM,YAAwC;AAAA,EAA9C;AACL,SAAO,QAAqB,CAAC;AAAA;AAAA,EAEtB,eAAe,gBAAqB,CAAC,GAAG;AAC7C,WAAO,IAAI,0BAAU,eAAe,KAAK,KAAK;AAAA,EAChD;AAAA,EAEO,IAAI,QAAgB;AACzB,WAAO,KAAK,MAAM,KAAK,CAAC,SAAS,KAAK,WAAW,MAAM;AAAA,EACzD;AAAA,EAEO,KAAK,YAAuC;AACjD,WAAO,KAAK,MAAM,OAAQ,CAAC,SAAS;AAClC,iBAAW,SAAS,YAAY;AAC9B,YACE,WAAW,eAAe,KAAK,KAC/B,KAAK,KAAK,MAAM,WAAW,KAAK,GAChC;AACA,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAE;AAAA,EACJ;AAAA,EAEO,QAAQ,WAAmB;AAChC,UAAM,cAAc,KAAK,KAAK,EAAE,UAAU,CAAC;AAC3C,uCAAiB,yDAAyD,WAAW,YAAY,MAAM;AAEvG,gBAAY,QAAQ,CAAC,SAAS,KAAK,OAAO,CAAC;AAC3C,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,QAAQ,YAAuC;AACpD,WAAO,IAAI,mBAAuB,KAAK,OAAO,UAAU;AAAA,EAC1D;AAAA,EAEO,QAAQ;AACb,SAAK,QAAQ,CAAC;AAAA,EAChB;AAAA,EAEO,WAAW;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/core/src/matchmaker/driver/index.ts
|
|
2
|
+
import { debugMatchMaking } from "../../Debug";
|
|
2
3
|
import { Query } from "./Query";
|
|
3
4
|
import { RoomCache } from "./RoomData";
|
|
4
|
-
|
|
5
|
+
var LocalDriver = class {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.rooms = [];
|
|
7
8
|
}
|
|
@@ -23,7 +24,7 @@ class LocalDriver {
|
|
|
23
24
|
}
|
|
24
25
|
cleanup(processId) {
|
|
25
26
|
const cachedRooms = this.find({ processId });
|
|
26
|
-
|
|
27
|
+
debugMatchMaking("removing stale rooms by processId %s (%s rooms found)", processId, cachedRooms.length);
|
|
27
28
|
cachedRooms.forEach((room) => room.remove());
|
|
28
29
|
return Promise.resolve();
|
|
29
30
|
}
|
|
@@ -35,7 +36,7 @@ class LocalDriver {
|
|
|
35
36
|
}
|
|
36
37
|
shutdown() {
|
|
37
38
|
}
|
|
38
|
-
}
|
|
39
|
+
};
|
|
39
40
|
export {
|
|
40
41
|
LocalDriver
|
|
41
42
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/matchmaker/driver/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { logger } from \"../../Logger\";\nimport { IRoomListingData, SortOptions, RoomListingData, QueryHelpers, MatchMakerDriver } from \"./interfaces\";\n\n// re-export\nexport type { IRoomListingData, SortOptions, RoomListingData, QueryHelpers, MatchMakerDriver };\n\nimport { Query } from './Query';\nimport { RoomCache } from './RoomData';\n\nexport class LocalDriver implements MatchMakerDriver {\n public rooms: RoomCache[] = [];\n\n public createInstance(initialValues: any = {}) {\n return new RoomCache(initialValues, this.rooms);\n }\n\n public has(roomId: string) {\n return this.rooms.some((room) => room.roomId === roomId);\n }\n\n public find(conditions: Partial<IRoomListingData>) {\n return this.rooms.filter(((room) => {\n for (const field in conditions) {\n if (\n conditions.hasOwnProperty(field) &&\n room[field] !== conditions[field]\n ) {\n return false;\n }\n }\n return true;\n }));\n }\n\n public cleanup(processId: string) {\n const cachedRooms = this.find({ processId });\n
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { debugMatchMaking } from \"../../Debug\";\nimport { logger } from \"../../Logger\";\nimport { IRoomListingData, SortOptions, RoomListingData, QueryHelpers, MatchMakerDriver } from \"./interfaces\";\n\n// re-export\nexport type { IRoomListingData, SortOptions, RoomListingData, QueryHelpers, MatchMakerDriver };\n\nimport { Query } from './Query';\nimport { RoomCache } from './RoomData';\n\nexport class LocalDriver implements MatchMakerDriver {\n public rooms: RoomCache[] = [];\n\n public createInstance(initialValues: any = {}) {\n return new RoomCache(initialValues, this.rooms);\n }\n\n public has(roomId: string) {\n return this.rooms.some((room) => room.roomId === roomId);\n }\n\n public find(conditions: Partial<IRoomListingData>) {\n return this.rooms.filter(((room) => {\n for (const field in conditions) {\n if (\n conditions.hasOwnProperty(field) &&\n room[field] !== conditions[field]\n ) {\n return false;\n }\n }\n return true;\n }));\n }\n\n public cleanup(processId: string) {\n const cachedRooms = this.find({ processId });\n debugMatchMaking(\"removing stale rooms by processId %s (%s rooms found)\", processId, cachedRooms.length);\n\n cachedRooms.forEach((room) => room.remove());\n return Promise.resolve();\n }\n\n public findOne(conditions: Partial<IRoomListingData>) {\n return new Query<RoomListingData>(this.rooms, conditions) as any as QueryHelpers<RoomListingData>;\n }\n\n public clear() {\n this.rooms = [];\n }\n\n public shutdown() {\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,wBAAwB;AAOjC,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAEnB,IAAM,cAAN,MAA8C;AAAA,EAA9C;AACL,SAAO,QAAqB,CAAC;AAAA;AAAA,EAEtB,eAAe,gBAAqB,CAAC,GAAG;AAC7C,WAAO,IAAI,UAAU,eAAe,KAAK,KAAK;AAAA,EAChD;AAAA,EAEO,IAAI,QAAgB;AACzB,WAAO,KAAK,MAAM,KAAK,CAAC,SAAS,KAAK,WAAW,MAAM;AAAA,EACzD;AAAA,EAEO,KAAK,YAAuC;AACjD,WAAO,KAAK,MAAM,OAAQ,CAAC,SAAS;AAClC,iBAAW,SAAS,YAAY;AAC9B,YACE,WAAW,eAAe,KAAK,KAC/B,KAAK,KAAK,MAAM,WAAW,KAAK,GAChC;AACA,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAE;AAAA,EACJ;AAAA,EAEO,QAAQ,WAAmB;AAChC,UAAM,cAAc,KAAK,KAAK,EAAE,UAAU,CAAC;AAC3C,qBAAiB,yDAAyD,WAAW,YAAY,MAAM;AAEvG,gBAAY,QAAQ,CAAC,SAAS,KAAK,OAAO,CAAC;AAC3C,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,QAAQ,YAAuC;AACpD,WAAO,IAAI,MAAuB,KAAK,OAAO,UAAU;AAAA,EAC1D;AAAA,EAEO,QAAQ;AACb,SAAK,QAAQ,CAAC;AAAA,EAChB;AAAA,EAEO,WAAW;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IRoomCache, SortOptions, RoomCache, MatchMakerDriver } from '../api.js';
|
|
2
|
+
export type { IRoomCache, SortOptions, RoomCache, MatchMakerDriver };
|
|
3
|
+
import { RoomData } from './RoomData.js';
|
|
4
|
+
export declare class LocalDriver implements MatchMakerDriver {
|
|
5
|
+
rooms: IRoomCache[];
|
|
6
|
+
createInstance(initialValues?: any): RoomData;
|
|
7
|
+
has(roomId: string): boolean;
|
|
8
|
+
query(conditions: Partial<IRoomCache>, sortOptions?: SortOptions): RoomCache<any>[];
|
|
9
|
+
cleanup(processId: string): Promise<void>;
|
|
10
|
+
findOne(conditions: Partial<IRoomCache>, sortOptions?: SortOptions): Promise<RoomCache>;
|
|
11
|
+
clear(): void;
|
|
12
|
+
shutdown(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var LocalDriver_exports = {};
|
|
19
|
+
__export(LocalDriver_exports, {
|
|
20
|
+
LocalDriver: () => LocalDriver
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(LocalDriver_exports);
|
|
23
|
+
var import_Debug = require("../../../Debug.js");
|
|
24
|
+
var import_Query = require("./Query.js");
|
|
25
|
+
var import_RoomData = require("./RoomData.js");
|
|
26
|
+
class LocalDriver {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.rooms = [];
|
|
29
|
+
}
|
|
30
|
+
createInstance(initialValues = {}) {
|
|
31
|
+
return new import_RoomData.RoomData(initialValues, this.rooms);
|
|
32
|
+
}
|
|
33
|
+
has(roomId) {
|
|
34
|
+
return this.rooms.some((room) => room.roomId === roomId);
|
|
35
|
+
}
|
|
36
|
+
query(conditions, sortOptions) {
|
|
37
|
+
const query = new import_Query.Query(this.rooms, conditions);
|
|
38
|
+
if (sortOptions) {
|
|
39
|
+
query.sort(sortOptions);
|
|
40
|
+
}
|
|
41
|
+
return query.filter(conditions);
|
|
42
|
+
}
|
|
43
|
+
cleanup(processId) {
|
|
44
|
+
const cachedRooms = this.query({ processId });
|
|
45
|
+
(0, import_Debug.debugMatchMaking)("removing stale rooms by processId %s (%s rooms found)", processId, cachedRooms.length);
|
|
46
|
+
cachedRooms.forEach((room) => room.remove());
|
|
47
|
+
return Promise.resolve();
|
|
48
|
+
}
|
|
49
|
+
findOne(conditions, sortOptions) {
|
|
50
|
+
const query = new import_Query.Query(this.rooms, conditions);
|
|
51
|
+
if (sortOptions) {
|
|
52
|
+
query.sort(sortOptions);
|
|
53
|
+
}
|
|
54
|
+
return query;
|
|
55
|
+
}
|
|
56
|
+
clear() {
|
|
57
|
+
this.rooms = [];
|
|
58
|
+
}
|
|
59
|
+
shutdown() {
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
LocalDriver
|
|
65
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/matchmaker/driver/local/LocalDriver.ts"],
|
|
4
|
+
"sourcesContent": ["import { debugMatchMaking } from '../../../Debug.js';\nimport { IRoomCache, SortOptions, RoomCache, MatchMakerDriver } from '../api.js';\n\n// re-export\nexport type { IRoomCache, SortOptions, RoomCache, MatchMakerDriver };\n\nimport { Query } from './Query.js';\nimport { RoomData } from './RoomData.js';\n\nexport class LocalDriver implements MatchMakerDriver {\n public rooms: IRoomCache[] = [];\n\n public createInstance(initialValues: any = {}) {\n return new RoomData(initialValues, this.rooms);\n }\n\n public has(roomId: string) {\n return this.rooms.some((room) => room.roomId === roomId);\n }\n\n public query(conditions: Partial<IRoomCache>, sortOptions?: SortOptions) {\n const query = new Query<RoomCache>(this.rooms, conditions);\n\n if (sortOptions) {\n query.sort(sortOptions);\n }\n\n return query.filter(conditions);\n }\n\n public cleanup(processId: string) {\n const cachedRooms = this.query({ processId });\n debugMatchMaking(\"removing stale rooms by processId %s (%s rooms found)\", processId, cachedRooms.length);\n\n cachedRooms.forEach((room) => room.remove());\n return Promise.resolve();\n }\n\n public findOne(conditions: Partial<IRoomCache>, sortOptions?: SortOptions) {\n const query = new Query<RoomCache>(this.rooms, conditions);\n\n if (sortOptions) {\n query.sort(sortOptions);\n }\n\n return query as unknown as Promise<RoomCache>;\n }\n\n public clear() {\n this.rooms = [];\n }\n\n public shutdown() {\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AAMjC,mBAAsB;AACtB,sBAAyB;AAElB,MAAM,YAAwC;AAAA,EAA9C;AACL,SAAO,QAAsB,CAAC;AAAA;AAAA,EAEvB,eAAe,gBAAqB,CAAC,GAAG;AAC7C,WAAO,IAAI,yBAAS,eAAe,KAAK,KAAK;AAAA,EAC/C;AAAA,EAEO,IAAI,QAAgB;AACzB,WAAO,KAAK,MAAM,KAAK,CAAC,SAAS,KAAK,WAAW,MAAM;AAAA,EACzD;AAAA,EAEO,MAAM,YAAiC,aAA2B;AACvE,UAAM,QAAQ,IAAI,mBAAiB,KAAK,OAAO,UAAU;AAEzD,QAAI,aAAa;AACf,YAAM,KAAK,WAAW;AAAA,IACxB;AAEA,WAAO,MAAM,OAAO,UAAU;AAAA,EAChC;AAAA,EAEO,QAAQ,WAAmB;AAChC,UAAM,cAAc,KAAK,MAAM,EAAE,UAAU,CAAC;AAC5C,uCAAiB,yDAAyD,WAAW,YAAY,MAAM;AAEvG,gBAAY,QAAQ,CAAC,SAAS,KAAK,OAAO,CAAC;AAC3C,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,QAAQ,YAAiC,aAA2B;AACzE,UAAM,QAAQ,IAAI,mBAAiB,KAAK,OAAO,UAAU;AAEzD,QAAI,aAAa;AACf,YAAM,KAAK,WAAW;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,QAAQ;AACb,SAAK,QAAQ,CAAC;AAAA,EAChB;AAAA,EAEO,WAAW;AAAA,EAClB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// packages/core/src/matchmaker/driver/local/LocalDriver.ts
|
|
2
|
+
import { debugMatchMaking } from "../../../Debug.mjs";
|
|
3
|
+
import { Query } from "./Query.mjs";
|
|
4
|
+
import { RoomData } from "./RoomData.mjs";
|
|
5
|
+
var LocalDriver = class {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.rooms = [];
|
|
8
|
+
}
|
|
9
|
+
createInstance(initialValues = {}) {
|
|
10
|
+
return new RoomData(initialValues, this.rooms);
|
|
11
|
+
}
|
|
12
|
+
has(roomId) {
|
|
13
|
+
return this.rooms.some((room) => room.roomId === roomId);
|
|
14
|
+
}
|
|
15
|
+
query(conditions, sortOptions) {
|
|
16
|
+
const query = new Query(this.rooms, conditions);
|
|
17
|
+
if (sortOptions) {
|
|
18
|
+
query.sort(sortOptions);
|
|
19
|
+
}
|
|
20
|
+
return query.filter(conditions);
|
|
21
|
+
}
|
|
22
|
+
cleanup(processId) {
|
|
23
|
+
const cachedRooms = this.query({ processId });
|
|
24
|
+
debugMatchMaking("removing stale rooms by processId %s (%s rooms found)", processId, cachedRooms.length);
|
|
25
|
+
cachedRooms.forEach((room) => room.remove());
|
|
26
|
+
return Promise.resolve();
|
|
27
|
+
}
|
|
28
|
+
findOne(conditions, sortOptions) {
|
|
29
|
+
const query = new Query(this.rooms, conditions);
|
|
30
|
+
if (sortOptions) {
|
|
31
|
+
query.sort(sortOptions);
|
|
32
|
+
}
|
|
33
|
+
return query;
|
|
34
|
+
}
|
|
35
|
+
clear() {
|
|
36
|
+
this.rooms = [];
|
|
37
|
+
}
|
|
38
|
+
shutdown() {
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
LocalDriver
|
|
43
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/matchmaker/driver/local/LocalDriver.ts"],
|
|
4
|
+
"sourcesContent": ["import { debugMatchMaking } from '../../../Debug.js';\nimport { IRoomCache, SortOptions, RoomCache, MatchMakerDriver } from '../api.js';\n\n// re-export\nexport type { IRoomCache, SortOptions, RoomCache, MatchMakerDriver };\n\nimport { Query } from './Query.js';\nimport { RoomData } from './RoomData.js';\n\nexport class LocalDriver implements MatchMakerDriver {\n public rooms: IRoomCache[] = [];\n\n public createInstance(initialValues: any = {}) {\n return new RoomData(initialValues, this.rooms);\n }\n\n public has(roomId: string) {\n return this.rooms.some((room) => room.roomId === roomId);\n }\n\n public query(conditions: Partial<IRoomCache>, sortOptions?: SortOptions) {\n const query = new Query<RoomCache>(this.rooms, conditions);\n\n if (sortOptions) {\n query.sort(sortOptions);\n }\n\n return query.filter(conditions);\n }\n\n public cleanup(processId: string) {\n const cachedRooms = this.query({ processId });\n debugMatchMaking(\"removing stale rooms by processId %s (%s rooms found)\", processId, cachedRooms.length);\n\n cachedRooms.forEach((room) => room.remove());\n return Promise.resolve();\n }\n\n public findOne(conditions: Partial<IRoomCache>, sortOptions?: SortOptions) {\n const query = new Query<RoomCache>(this.rooms, conditions);\n\n if (sortOptions) {\n query.sort(sortOptions);\n }\n\n return query as unknown as Promise<RoomCache>;\n }\n\n public clear() {\n this.rooms = [];\n }\n\n public shutdown() {\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,wBAAwB;AAMjC,SAAS,aAAa;AACtB,SAAS,gBAAgB;AAElB,IAAM,cAAN,MAA8C;AAAA,EAA9C;AACL,SAAO,QAAsB,CAAC;AAAA;AAAA,EAEvB,eAAe,gBAAqB,CAAC,GAAG;AAC7C,WAAO,IAAI,SAAS,eAAe,KAAK,KAAK;AAAA,EAC/C;AAAA,EAEO,IAAI,QAAgB;AACzB,WAAO,KAAK,MAAM,KAAK,CAAC,SAAS,KAAK,WAAW,MAAM;AAAA,EACzD;AAAA,EAEO,MAAM,YAAiC,aAA2B;AACvE,UAAM,QAAQ,IAAI,MAAiB,KAAK,OAAO,UAAU;AAEzD,QAAI,aAAa;AACf,YAAM,KAAK,WAAW;AAAA,IACxB;AAEA,WAAO,MAAM,OAAO,UAAU;AAAA,EAChC;AAAA,EAEO,QAAQ,WAAmB;AAChC,UAAM,cAAc,KAAK,MAAM,EAAE,UAAU,CAAC;AAC5C,qBAAiB,yDAAyD,WAAW,YAAY,MAAM;AAEvG,gBAAY,QAAQ,CAAC,SAAS,KAAK,OAAO,CAAC;AAC3C,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,QAAQ,YAAiC,aAA2B;AACzE,UAAM,QAAQ,IAAI,MAAiB,KAAK,OAAO,UAAU;AAEzD,QAAI,aAAa;AACf,YAAM,KAAK,WAAW;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,QAAQ;AACb,SAAK,QAAQ,CAAC;AAAA,EAChB;AAAA,EAEO,WAAW;AAAA,EAClB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SortOptions } from '../api.js';
|
|
2
|
+
export declare class Query<T> {
|
|
3
|
+
private $rooms;
|
|
4
|
+
private conditions;
|
|
5
|
+
constructor(rooms: any[], conditions: any);
|
|
6
|
+
sort(options: SortOptions): void;
|
|
7
|
+
filter(conditions: any): T[];
|
|
8
|
+
then(resolve: any, reject: any): any;
|
|
9
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var Query_exports = {};
|
|
19
|
+
__export(Query_exports, {
|
|
20
|
+
Query: () => Query
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(Query_exports);
|
|
23
|
+
class Query {
|
|
24
|
+
constructor(rooms, conditions) {
|
|
25
|
+
this.$rooms = rooms.slice(0);
|
|
26
|
+
this.conditions = conditions;
|
|
27
|
+
}
|
|
28
|
+
sort(options) {
|
|
29
|
+
this.$rooms = this.$rooms.sort((room1, room2) => {
|
|
30
|
+
for (const field in options) {
|
|
31
|
+
if (options.hasOwnProperty(field)) {
|
|
32
|
+
const direction = options[field];
|
|
33
|
+
const isAscending = direction === 1 || direction === "asc" || direction === "ascending";
|
|
34
|
+
if (isAscending) {
|
|
35
|
+
if (room1[field] > room2[field]) {
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
if (room1[field] < room2[field]) {
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
if (room1[field] > room2[field]) {
|
|
43
|
+
return -1;
|
|
44
|
+
}
|
|
45
|
+
if (room1[field] < room2[field]) {
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
filter(conditions) {
|
|
54
|
+
return this.$rooms.filter((room) => {
|
|
55
|
+
for (const field in conditions) {
|
|
56
|
+
if (conditions.hasOwnProperty(field) && room[field] !== conditions[field]) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
then(resolve, reject) {
|
|
64
|
+
const result = this.$rooms.find((room) => {
|
|
65
|
+
for (const field in this.conditions) {
|
|
66
|
+
if (this.conditions.hasOwnProperty(field) && room[field] !== this.conditions[field]) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
});
|
|
72
|
+
return resolve(result);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
Query
|
|
78
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/matchmaker/driver/local/Query.ts"],
|
|
4
|
+
"sourcesContent": ["import { SortOptions } from '../api.js';\n\nexport class Query<T> {\n private $rooms: T[];\n private conditions: any;\n\n constructor(rooms: any[], conditions) {\n this.$rooms = rooms.slice(0);\n this.conditions = conditions;\n }\n\n public sort(options: SortOptions) {\n this.$rooms = this.$rooms.sort((room1, room2) => {\n for (const field in options) {\n if (options.hasOwnProperty(field)) {\n const direction = options[field];\n const isAscending = (direction === 1 || direction === 'asc' || direction === 'ascending');\n\n if (isAscending) {\n if (room1[field] > room2[field]) { return 1; }\n if (room1[field] < room2[field]) { return -1; }\n\n } else {\n if (room1[field] > room2[field]) { return -1; }\n if (room1[field] < room2[field]) { return 1; }\n }\n }\n }\n });\n }\n\n public filter(conditions: any) {\n return this.$rooms.filter(((room) => {\n for (const field in conditions) {\n if (\n conditions.hasOwnProperty(field) &&\n room[field] !== conditions[field]\n ) {\n return false;\n }\n }\n return true;\n }));\n\n }\n\n public then(resolve, reject) {\n const result: any = this.$rooms.find(((room) => {\n for (const field in this.conditions) {\n if (\n this.conditions.hasOwnProperty(field) &&\n room[field] !== this.conditions[field]\n ) {\n return false;\n }\n }\n return true;\n }));\n return resolve(result);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,MAAS;AAAA,EAIpB,YAAY,OAAc,YAAY;AACpC,SAAK,SAAS,MAAM,MAAM,CAAC;AAC3B,SAAK,aAAa;AAAA,EACpB;AAAA,EAEO,KAAK,SAAsB;AAChC,SAAK,SAAS,KAAK,OAAO,KAAK,CAAC,OAAO,UAAU;AAC/C,iBAAW,SAAS,SAAS;AAC3B,YAAI,QAAQ,eAAe,KAAK,GAAG;AACjC,gBAAM,YAAY,QAAQ,KAAK;AAC/B,gBAAM,cAAe,cAAc,KAAK,cAAc,SAAS,cAAc;AAE7E,cAAI,aAAa;AACf,gBAAI,MAAM,KAAK,IAAI,MAAM,KAAK,GAAG;AAAE,qBAAO;AAAA,YAAG;AAC7C,gBAAI,MAAM,KAAK,IAAI,MAAM,KAAK,GAAG;AAAE,qBAAO;AAAA,YAAI;AAAA,UAEhD,OAAO;AACL,gBAAI,MAAM,KAAK,IAAI,MAAM,KAAK,GAAG;AAAE,qBAAO;AAAA,YAAI;AAC9C,gBAAI,MAAM,KAAK,IAAI,MAAM,KAAK,GAAG;AAAE,qBAAO;AAAA,YAAG;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEO,OAAO,YAAiB;AAC7B,WAAO,KAAK,OAAO,OAAQ,CAAC,SAAS;AACnC,iBAAW,SAAS,YAAY;AAC9B,YACE,WAAW,eAAe,KAAK,KAC/B,KAAK,KAAK,MAAM,WAAW,KAAK,GAChC;AACA,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAE;AAAA,EAEJ;AAAA,EAEO,KAAK,SAAS,QAAQ;AAC3B,UAAM,SAAc,KAAK,OAAO,KAAM,CAAC,SAAS;AAC9C,iBAAW,SAAS,KAAK,YAAY;AACnC,YACE,KAAK,WAAW,eAAe,KAAK,KACpC,KAAK,KAAK,MAAM,KAAK,WAAW,KAAK,GACrC;AACA,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAE;AACF,WAAO,QAAQ,MAAM;AAAA,EACvB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// packages/core/src/matchmaker/driver/local/Query.ts
|
|
2
|
+
var Query = class {
|
|
3
|
+
constructor(rooms, conditions) {
|
|
4
|
+
this.$rooms = rooms.slice(0);
|
|
5
|
+
this.conditions = conditions;
|
|
6
|
+
}
|
|
7
|
+
sort(options) {
|
|
8
|
+
this.$rooms = this.$rooms.sort((room1, room2) => {
|
|
9
|
+
for (const field in options) {
|
|
10
|
+
if (options.hasOwnProperty(field)) {
|
|
11
|
+
const direction = options[field];
|
|
12
|
+
const isAscending = direction === 1 || direction === "asc" || direction === "ascending";
|
|
13
|
+
if (isAscending) {
|
|
14
|
+
if (room1[field] > room2[field]) {
|
|
15
|
+
return 1;
|
|
16
|
+
}
|
|
17
|
+
if (room1[field] < room2[field]) {
|
|
18
|
+
return -1;
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
if (room1[field] > room2[field]) {
|
|
22
|
+
return -1;
|
|
23
|
+
}
|
|
24
|
+
if (room1[field] < room2[field]) {
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
filter(conditions) {
|
|
33
|
+
return this.$rooms.filter((room) => {
|
|
34
|
+
for (const field in conditions) {
|
|
35
|
+
if (conditions.hasOwnProperty(field) && room[field] !== conditions[field]) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
then(resolve, reject) {
|
|
43
|
+
const result = this.$rooms.find((room) => {
|
|
44
|
+
for (const field in this.conditions) {
|
|
45
|
+
if (this.conditions.hasOwnProperty(field) && room[field] !== this.conditions[field]) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
});
|
|
51
|
+
return resolve(result);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
Query
|
|
56
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/matchmaker/driver/local/Query.ts"],
|
|
4
|
+
"sourcesContent": ["import { SortOptions } from '../api.js';\n\nexport class Query<T> {\n private $rooms: T[];\n private conditions: any;\n\n constructor(rooms: any[], conditions) {\n this.$rooms = rooms.slice(0);\n this.conditions = conditions;\n }\n\n public sort(options: SortOptions) {\n this.$rooms = this.$rooms.sort((room1, room2) => {\n for (const field in options) {\n if (options.hasOwnProperty(field)) {\n const direction = options[field];\n const isAscending = (direction === 1 || direction === 'asc' || direction === 'ascending');\n\n if (isAscending) {\n if (room1[field] > room2[field]) { return 1; }\n if (room1[field] < room2[field]) { return -1; }\n\n } else {\n if (room1[field] > room2[field]) { return -1; }\n if (room1[field] < room2[field]) { return 1; }\n }\n }\n }\n });\n }\n\n public filter(conditions: any) {\n return this.$rooms.filter(((room) => {\n for (const field in conditions) {\n if (\n conditions.hasOwnProperty(field) &&\n room[field] !== conditions[field]\n ) {\n return false;\n }\n }\n return true;\n }));\n\n }\n\n public then(resolve, reject) {\n const result: any = this.$rooms.find(((room) => {\n for (const field in this.conditions) {\n if (\n this.conditions.hasOwnProperty(field) &&\n room[field] !== this.conditions[field]\n ) {\n return false;\n }\n }\n return true;\n }));\n return resolve(result);\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAEO,IAAM,QAAN,MAAe;AAAA,EAIpB,YAAY,OAAc,YAAY;AACpC,SAAK,SAAS,MAAM,MAAM,CAAC;AAC3B,SAAK,aAAa;AAAA,EACpB;AAAA,EAEO,KAAK,SAAsB;AAChC,SAAK,SAAS,KAAK,OAAO,KAAK,CAAC,OAAO,UAAU;AAC/C,iBAAW,SAAS,SAAS;AAC3B,YAAI,QAAQ,eAAe,KAAK,GAAG;AACjC,gBAAM,YAAY,QAAQ,KAAK;AAC/B,gBAAM,cAAe,cAAc,KAAK,cAAc,SAAS,cAAc;AAE7E,cAAI,aAAa;AACf,gBAAI,MAAM,KAAK,IAAI,MAAM,KAAK,GAAG;AAAE,qBAAO;AAAA,YAAG;AAC7C,gBAAI,MAAM,KAAK,IAAI,MAAM,KAAK,GAAG;AAAE,qBAAO;AAAA,YAAI;AAAA,UAEhD,OAAO;AACL,gBAAI,MAAM,KAAK,IAAI,MAAM,KAAK,GAAG;AAAE,qBAAO;AAAA,YAAI;AAC9C,gBAAI,MAAM,KAAK,IAAI,MAAM,KAAK,GAAG;AAAE,qBAAO;AAAA,YAAG;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEO,OAAO,YAAiB;AAC7B,WAAO,KAAK,OAAO,OAAQ,CAAC,SAAS;AACnC,iBAAW,SAAS,YAAY;AAC9B,YACE,WAAW,eAAe,KAAK,KAC/B,KAAK,KAAK,MAAM,WAAW,KAAK,GAChC;AACA,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAE;AAAA,EAEJ;AAAA,EAEO,KAAK,SAAS,QAAQ;AAC3B,UAAM,SAAc,KAAK,OAAO,KAAM,CAAC,SAAS;AAC9C,iBAAW,SAAS,KAAK,YAAY;AACnC,YACE,KAAK,WAAW,eAAe,KAAK,KACpC,KAAK,KAAK,MAAM,KAAK,WAAW,KAAK,GACrC;AACA,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAE;AACF,WAAO,QAAQ,MAAM;AAAA,EACvB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RoomCache, IRoomCache } from '../api.js';
|
|
2
|
+
export declare class RoomData implements RoomCache {
|
|
3
|
+
clients: number;
|
|
4
|
+
locked: boolean;
|
|
5
|
+
private: boolean;
|
|
6
|
+
maxClients: number;
|
|
7
|
+
metadata: any;
|
|
8
|
+
name: string;
|
|
9
|
+
publicAddress: string;
|
|
10
|
+
processId: string;
|
|
11
|
+
roomId: string;
|
|
12
|
+
createdAt: Date;
|
|
13
|
+
unlisted: boolean;
|
|
14
|
+
private $rooms;
|
|
15
|
+
constructor(initialValues: any, rooms: IRoomCache[]);
|
|
16
|
+
save(): void;
|
|
17
|
+
updateOne(operations: any): void;
|
|
18
|
+
remove(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var RoomData_exports = {};
|
|
19
|
+
__export(RoomData_exports, {
|
|
20
|
+
RoomData: () => RoomData
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(RoomData_exports);
|
|
23
|
+
var import_Utils = require("../../../utils/Utils.js");
|
|
24
|
+
class RoomData {
|
|
25
|
+
constructor(initialValues, rooms) {
|
|
26
|
+
this.clients = 0;
|
|
27
|
+
this.locked = false;
|
|
28
|
+
this.private = false;
|
|
29
|
+
this.maxClients = Infinity;
|
|
30
|
+
this.unlisted = false;
|
|
31
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
32
|
+
for (const field in initialValues) {
|
|
33
|
+
if (initialValues.hasOwnProperty(field)) {
|
|
34
|
+
this[field] = initialValues[field];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
Object.defineProperty(this, "$rooms", {
|
|
38
|
+
value: rooms,
|
|
39
|
+
enumerable: false,
|
|
40
|
+
writable: true
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
save() {
|
|
44
|
+
if (this.$rooms.indexOf(this) === -1) {
|
|
45
|
+
this.$rooms.push(this);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
updateOne(operations) {
|
|
49
|
+
if (operations.$set) {
|
|
50
|
+
for (const field in operations.$set) {
|
|
51
|
+
if (operations.$set.hasOwnProperty(field)) {
|
|
52
|
+
this[field] = operations.$set[field];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (operations.$inc) {
|
|
57
|
+
for (const field in operations.$inc) {
|
|
58
|
+
if (operations.$inc.hasOwnProperty(field)) {
|
|
59
|
+
this[field] += operations.$inc[field];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
remove() {
|
|
65
|
+
if (!this.$rooms) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const roomIndex = this.$rooms.indexOf(this);
|
|
69
|
+
if (roomIndex === -1) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
(0, import_Utils.spliceOne)(this.$rooms, roomIndex);
|
|
73
|
+
this.$rooms = null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
RoomData
|
|
79
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/matchmaker/driver/local/RoomData.ts"],
|
|
4
|
+
"sourcesContent": ["import { spliceOne } from '../../../utils/Utils.js';\nimport { RoomCache, IRoomCache } from '../api.js';\n\nexport class RoomData implements RoomCache {\n public clients: number = 0;\n public locked: boolean = false;\n public private: boolean = false;\n public maxClients: number = Infinity;\n public metadata: any;\n public name: string;\n public publicAddress: string;\n public processId: string;\n public roomId: string;\n public createdAt: Date;\n public unlisted: boolean = false;\n\n private $rooms: RoomCache[];\n\n constructor(initialValues: any, rooms: IRoomCache[]) {\n this.createdAt = new Date();\n\n for (const field in initialValues) {\n if (initialValues.hasOwnProperty(field)) {\n this[field] = initialValues[field];\n }\n }\n\n // make $rooms non-enumerable, so it can be serialized (circular references)\n Object.defineProperty(this, \"$rooms\", {\n value: rooms,\n enumerable: false,\n writable: true,\n });\n }\n\n public save() {\n if (this.$rooms.indexOf(this) === -1) {\n this.$rooms.push(this);\n }\n }\n\n public updateOne(operations: any) {\n if (operations.$set) {\n for (const field in operations.$set) {\n if (operations.$set.hasOwnProperty(field)) {\n this[field] = operations.$set[field];\n }\n }\n }\n\n if (operations.$inc) {\n for (const field in operations.$inc) {\n if (operations.$inc.hasOwnProperty(field)) {\n this[field] += operations.$inc[field];\n }\n }\n }\n }\n\n public remove() {\n //\n // WORKAROUND: prevent calling `.remove()` multiple times\n // Seems to happen during disconnect + dispose: https://github.com/colyseus/colyseus/issues/390\n //\n if (!this.$rooms) { return; }\n\n const roomIndex = this.$rooms.indexOf(this);\n if (roomIndex === -1) { return; }\n\n spliceOne(this.$rooms, roomIndex);\n this.$rooms = null;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAGnB,MAAM,SAA8B;AAAA,EAezC,YAAY,eAAoB,OAAqB;AAdrD,SAAO,UAAkB;AACzB,SAAO,SAAkB;AACzB,SAAO,UAAmB;AAC1B,SAAO,aAAqB;AAO5B,SAAO,WAAoB;AAKzB,SAAK,YAAY,oBAAI,KAAK;AAE1B,eAAW,SAAS,eAAe;AACjC,UAAI,cAAc,eAAe,KAAK,GAAG;AACvC,aAAK,KAAK,IAAI,cAAc,KAAK;AAAA,MACnC;AAAA,IACF;AAGA,WAAO,eAAe,MAAM,UAAU;AAAA,MACpC,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAAA,EAEO,OAAO;AACZ,QAAI,KAAK,OAAO,QAAQ,IAAI,MAAM,IAAI;AACpC,WAAK,OAAO,KAAK,IAAI;AAAA,IACvB;AAAA,EACF;AAAA,EAEO,UAAU,YAAiB;AAChC,QAAI,WAAW,MAAM;AACnB,iBAAW,SAAS,WAAW,MAAM;AACnC,YAAI,WAAW,KAAK,eAAe,KAAK,GAAG;AACzC,eAAK,KAAK,IAAI,WAAW,KAAK,KAAK;AAAA,QACrC;AAAA,MACF;AAAA,IACF;AAEA,QAAI,WAAW,MAAM;AACnB,iBAAW,SAAS,WAAW,MAAM;AACnC,YAAI,WAAW,KAAK,eAAe,KAAK,GAAG;AACzC,eAAK,KAAK,KAAK,WAAW,KAAK,KAAK;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEO,SAAS;AAKd,QAAI,CAAC,KAAK,QAAQ;AAAE;AAAA,IAAQ;AAE5B,UAAM,YAAY,KAAK,OAAO,QAAQ,IAAI;AAC1C,QAAI,cAAc,IAAI;AAAE;AAAA,IAAQ;AAEhC,gCAAU,KAAK,QAAQ,SAAS;AAChC,SAAK,SAAS;AAAA,EAChB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// packages/core/src/matchmaker/driver/local/RoomData.ts
|
|
2
|
+
import { spliceOne } from "../../../utils/Utils.mjs";
|
|
3
|
+
var RoomData = class {
|
|
4
|
+
constructor(initialValues, rooms) {
|
|
5
|
+
this.clients = 0;
|
|
6
|
+
this.locked = false;
|
|
7
|
+
this.private = false;
|
|
8
|
+
this.maxClients = Infinity;
|
|
9
|
+
this.unlisted = false;
|
|
10
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
11
|
+
for (const field in initialValues) {
|
|
12
|
+
if (initialValues.hasOwnProperty(field)) {
|
|
13
|
+
this[field] = initialValues[field];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(this, "$rooms", {
|
|
17
|
+
value: rooms,
|
|
18
|
+
enumerable: false,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
save() {
|
|
23
|
+
if (this.$rooms.indexOf(this) === -1) {
|
|
24
|
+
this.$rooms.push(this);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
updateOne(operations) {
|
|
28
|
+
if (operations.$set) {
|
|
29
|
+
for (const field in operations.$set) {
|
|
30
|
+
if (operations.$set.hasOwnProperty(field)) {
|
|
31
|
+
this[field] = operations.$set[field];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (operations.$inc) {
|
|
36
|
+
for (const field in operations.$inc) {
|
|
37
|
+
if (operations.$inc.hasOwnProperty(field)) {
|
|
38
|
+
this[field] += operations.$inc[field];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
remove() {
|
|
44
|
+
if (!this.$rooms) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const roomIndex = this.$rooms.indexOf(this);
|
|
48
|
+
if (roomIndex === -1) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
spliceOne(this.$rooms, roomIndex);
|
|
52
|
+
this.$rooms = null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
RoomData
|
|
57
|
+
};
|