@colyseus/core 0.16.0-preview.21 → 0.16.0-preview.28
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/MatchMaker.d.ts +15 -14
- package/build/MatchMaker.js +81 -65
- package/build/MatchMaker.js.map +2 -2
- package/build/MatchMaker.mjs +80 -64
- package/build/MatchMaker.mjs.map +2 -2
- package/build/Protocol.d.ts +3 -4
- package/build/Protocol.js +22 -20
- package/build/Protocol.js.map +2 -2
- package/build/Protocol.mjs +22 -20
- package/build/Protocol.mjs.map +2 -2
- package/build/Room.d.ts +30 -29
- package/build/Room.js +123 -84
- package/build/Room.js.map +2 -2
- package/build/Room.mjs +123 -84
- package/build/Room.mjs.map +2 -2
- package/build/Server.d.ts +0 -1
- package/build/Server.js +2 -2
- package/build/Server.js.map +2 -2
- package/build/Server.mjs +1 -1
- package/build/Server.mjs.map +2 -2
- package/build/Transport.d.ts +0 -5
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +2 -2
- package/build/index.mjs +1 -1
- package/build/index.mjs.map +1 -1
- package/build/matchmaker/Lobby.d.ts +2 -2
- package/build/matchmaker/Lobby.js.map +2 -2
- package/build/matchmaker/Lobby.mjs.map +2 -2
- package/build/matchmaker/RegisteredHandler.d.ts +4 -5
- package/build/matchmaker/RegisteredHandler.js +4 -3
- package/build/matchmaker/RegisteredHandler.js.map +2 -2
- package/build/matchmaker/RegisteredHandler.mjs +4 -3
- package/build/matchmaker/RegisteredHandler.mjs.map +2 -2
- package/build/matchmaker/controller.d.ts +1 -2
- package/build/matchmaker/driver/RoomData.d.ts +3 -3
- package/build/matchmaker/driver/RoomData.js +3 -3
- package/build/matchmaker/driver/RoomData.js.map +2 -2
- package/build/matchmaker/driver/RoomData.mjs +2 -2
- package/build/matchmaker/driver/RoomData.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 +6 -0
- package/build/matchmaker/driver/api.mjs.map +7 -0
- package/build/matchmaker/driver/index.d.ts +7 -7
- package/build/matchmaker/driver/index.js +1 -1
- package/build/matchmaker/driver/index.js.map +2 -2
- package/build/matchmaker/driver/index.mjs +2 -2
- package/build/matchmaker/driver/index.mjs.map +2 -2
- package/build/matchmaker/driver/interfaces.d.ts +7 -11
- package/build/matchmaker/driver/interfaces.js.map +1 -1
- 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 +42 -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 +55 -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 +56 -0
- package/build/matchmaker/driver/local/RoomData.mjs.map +7 -0
- package/build/presence/LocalPresence.d.ts +9 -2
- package/build/presence/LocalPresence.js +77 -3
- package/build/presence/LocalPresence.js.map +3 -3
- package/build/presence/LocalPresence.mjs +77 -3
- 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 +4 -4
- package/build/rooms/LobbyRoom.js.map +2 -2
- package/build/rooms/LobbyRoom.mjs.map +2 -2
- package/build/serializer/SchemaSerializer.d.ts +11 -10
- package/build/serializer/SchemaSerializer.js.map +2 -2
- package/build/serializer/SchemaSerializer.mjs.map +2 -2
- package/build/serializer/Serializer.d.ts +0 -1
- package/build/utils/Utils.d.ts +4 -2
- package/build/utils/Utils.js +11 -2
- package/build/utils/Utils.js.map +2 -2
- package/build/utils/Utils.mjs +10 -2
- package/build/utils/Utils.mjs.map +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/matchmaker/Lobby.ts"],
|
|
4
|
-
"sourcesContent": ["import * as matchMaker from '../MatchMaker';\n\nimport type { Room } from '../Room';\nimport {
|
|
5
|
-
"mappings": "AAAA,YAAY,gBAAgB;AAK5B,MAAM,gBAAgB;AAaf,SAAS,YAAY,MAAY,UAAmB,OAAO;AAChE,QAAM,UAAU,KAAK;AAErB,MAAI,QAAQ;AAAU;AAEtB,MAAI,SAAS;AACX,eAAW,SAAS,QAAQ,eAAe,GAAG,QAAQ,UAAU;AAAA,EAClE,WAAW,CAAC,QAAQ,SAAS;AAC3B,eAAW,SAAS,QAAQ,eAAe,GAAG,QAAQ,UAAU;AAAA,EAClE;AACF;AAEA,eAAsB,eAAe,
|
|
4
|
+
"sourcesContent": ["import * as matchMaker from '../MatchMaker';\n\nimport type { Room } from '../Room';\nimport { IRoomCache } from './driver/api';\n\nconst LOBBY_CHANNEL = '$lobby';\n\n/*\n * TODO: refactor this on v0.16\n *\n * Some users might be relying on \"1\" = \"removed\" from the lobby due to this workaround: https://github.com/colyseus/colyseus/issues/617\n * Though, for consistency, we should invert as \"0\" = \"invisible\" and \"1\" = \"visible\".\n *\n * - rename \"removed\" to \"isVisible\" and swap the logic\n * - emit \"visibility-change\" with inverted value (isVisible)\n * - update \"subscribeLobby\" to check \"1\" as \"isVisible\" instead of \"removed\"\n */\n\nexport function updateLobby(room: Room, removed: boolean = false) {\n const listing = room.listing;\n\n if (listing.unlisted) return;\n\n if (removed) {\n matchMaker.presence.publish(LOBBY_CHANNEL, `${listing.roomId},1`);\n } else if (!listing.private) {\n matchMaker.presence.publish(LOBBY_CHANNEL, `${listing.roomId},0`);\n }\n}\n\nexport async function subscribeLobby(callback: (roomId: string, roomListing: IRoomCache) => void) {\n const cb = async (message) => {\n const [roomId, isRemove] = message.split(',');\n\n if (isRemove === '1') {\n callback(roomId, null);\n\n } else {\n const room = (await matchMaker.query({ roomId }))[0];\n callback(roomId, room);\n }\n };\n\n await matchMaker.presence.subscribe(LOBBY_CHANNEL, cb);\n\n return () => matchMaker.presence.unsubscribe(LOBBY_CHANNEL, cb);\n}\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,gBAAgB;AAK5B,MAAM,gBAAgB;AAaf,SAAS,YAAY,MAAY,UAAmB,OAAO;AAChE,QAAM,UAAU,KAAK;AAErB,MAAI,QAAQ;AAAU;AAEtB,MAAI,SAAS;AACX,eAAW,SAAS,QAAQ,eAAe,GAAG,QAAQ,UAAU;AAAA,EAClE,WAAW,CAAC,QAAQ,SAAS;AAC3B,eAAW,SAAS,QAAQ,eAAe,GAAG,QAAQ,UAAU;AAAA,EAClE;AACF;AAEA,eAAsB,eAAe,UAA6D;AAChG,QAAM,KAAK,OAAO,YAAY;AAC5B,UAAM,CAAC,QAAQ,QAAQ,IAAI,QAAQ,MAAM,GAAG;AAE5C,QAAI,aAAa,KAAK;AACpB,eAAS,QAAQ,IAAI;AAAA,IAEvB,OAAO;AACL,YAAM,QAAQ,MAAM,WAAW,MAAM,EAAE,OAAO,CAAC,GAAG;AAClD,eAAS,QAAQ,IAAI;AAAA,IACvB;AAAA,EACF;AAEA,QAAM,WAAW,SAAS,UAAU,eAAe,EAAE;AAErD,SAAO,MAAM,WAAW,SAAS,YAAY,eAAe,EAAE;AAChE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { IncomingMessage } from 'http';
|
|
4
2
|
import { EventEmitter } from 'events';
|
|
5
|
-
import {
|
|
3
|
+
import { RoomCache, SortOptions } from './driver/api';
|
|
6
4
|
import { Room } from './../Room';
|
|
7
5
|
import { Type } from '../utils/types';
|
|
8
|
-
export declare const INVALID_OPTION_KEYS: Array<keyof
|
|
6
|
+
export declare const INVALID_OPTION_KEYS: Array<keyof RoomCache>;
|
|
9
7
|
export type ValidateAuthTokenCallback = (token: string, request?: IncomingMessage) => Promise<any>;
|
|
10
8
|
export declare class RegisteredHandler extends EventEmitter {
|
|
9
|
+
name: string;
|
|
11
10
|
klass: Type<Room>;
|
|
12
11
|
options: any;
|
|
13
12
|
filterOptions: string[];
|
|
14
13
|
sortOptions?: SortOptions;
|
|
15
|
-
constructor(klass: Type<Room>, options: any);
|
|
14
|
+
constructor(name: string, klass: Type<Room>, options: any);
|
|
16
15
|
enableRealtimeListing(): this;
|
|
17
16
|
filterBy(options: string[]): this;
|
|
18
17
|
sortBy(options: SortOptions): this;
|
|
@@ -39,15 +39,16 @@ const INVALID_OPTION_KEYS = [
|
|
|
39
39
|
"roomId"
|
|
40
40
|
];
|
|
41
41
|
class RegisteredHandler extends import_events.EventEmitter {
|
|
42
|
-
constructor(klass, options) {
|
|
42
|
+
constructor(name, klass, options) {
|
|
43
43
|
super();
|
|
44
|
+
this.name = name;
|
|
45
|
+
this.klass = klass;
|
|
46
|
+
this.options = options;
|
|
44
47
|
this.filterOptions = [];
|
|
45
48
|
if (typeof klass !== "function") {
|
|
46
49
|
import_Logger.logger.debug("You are likely not importing your room class correctly.");
|
|
47
50
|
throw new Error(`class is expected but ${typeof klass} was provided.`);
|
|
48
51
|
}
|
|
49
|
-
this.klass = klass;
|
|
50
|
-
this.options = options;
|
|
51
52
|
}
|
|
52
53
|
enableRealtimeListing() {
|
|
53
54
|
this.on("create", (room) => (0, import_Lobby.updateLobby)(room));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/matchmaker/RegisteredHandler.ts"],
|
|
4
|
-
"sourcesContent": ["import { IncomingMessage } from 'http';\nimport { EventEmitter } from 'events';\nimport { logger } from '../Logger';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA6B;AAC7B,oBAAuB;AAIvB,mBAA4B;AAG5B,IAAI,eAAoB;AACxB,IAAI;AAAE,iBAAe,QAAQ,gBAAgB;AAAG,SAAS,GAAP;AAAW;AAEtD,MAAM,
|
|
4
|
+
"sourcesContent": ["import { IncomingMessage } from 'http';\nimport { EventEmitter } from 'events';\nimport { logger } from '../Logger';\nimport { RoomCache, SortOptions } from './driver/api';\n\nimport { Room } from './../Room';\nimport { updateLobby } from './Lobby';\nimport { Type } from '../utils/types';\n\nlet ColyseusAuth: any = undefined;\ntry { ColyseusAuth = require('@colyseus/auth'); } catch (e) {}\n\nexport const INVALID_OPTION_KEYS: Array<keyof RoomCache> = [\n 'clients',\n 'locked',\n 'private',\n // 'maxClients', - maxClients can be useful as filter options\n 'metadata',\n 'name',\n 'processId',\n 'roomId',\n];\n\nexport type ValidateAuthTokenCallback = (token: string, request?: IncomingMessage) => Promise<any>;\n\nexport class RegisteredHandler extends EventEmitter {\n public filterOptions: string[] = [];\n public sortOptions?: SortOptions;\n\n constructor(\n public name: string,\n public klass: Type<Room>,\n public options: any\n ) {\n super();\n\n if (typeof(klass) !== 'function') {\n logger.debug('You are likely not importing your room class correctly.');\n throw new Error(`class is expected but ${typeof(klass)} was provided.`);\n }\n }\n\n public enableRealtimeListing() {\n this.on('create', (room) => updateLobby(room));\n this.on('lock', (room) => updateLobby(room));\n this.on('unlock', (room) => updateLobby(room));\n this.on('join', (room) => updateLobby(room));\n this.on('leave', (room, _, willDispose) => {\n if (!willDispose) {\n updateLobby(room);\n }\n });\n this.on('dispose', (room) => updateLobby(room, false));\n this.on('visibility-change', (room, isVisible) => updateLobby(room, isVisible));\n\n return this;\n }\n\n public filterBy(options: string[]) {\n this.filterOptions = options;\n return this;\n }\n\n public sortBy(options: SortOptions) {\n this.sortOptions = options;\n return this;\n }\n\n public getFilterOptions(options: any) {\n return this.filterOptions.reduce((prev, curr, i, arr) => {\n const field = arr[i];\n if (options.hasOwnProperty(field)) {\n if (INVALID_OPTION_KEYS.indexOf(field as any) !== -1) {\n logger.warn(`option \"${field}\" has internal usage and is going to be ignored.`);\n\n } else {\n prev[field] = options[field];\n }\n }\n return prev;\n }, {});\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA6B;AAC7B,oBAAuB;AAIvB,mBAA4B;AAG5B,IAAI,eAAoB;AACxB,IAAI;AAAE,iBAAe,QAAQ,gBAAgB;AAAG,SAAS,GAAP;AAAW;AAEtD,MAAM,sBAA8C;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,MAAM,0BAA0B,2BAAa;AAAA,EAIlD,YACS,MACA,OACA,SACP;AACA,UAAM;AAJC;AACA;AACA;AANT,SAAO,gBAA0B,CAAC;AAUhC,QAAI,OAAO,UAAW,YAAY;AAChC,2BAAO,MAAM,yDAAyD;AACtE,YAAM,IAAI,MAAM,yBAAyB,OAAO,qBAAsB;AAAA,IACxE;AAAA,EACF;AAAA,EAEO,wBAAwB;AAC7B,SAAK,GAAG,UAAU,CAAC,aAAS,0BAAY,IAAI,CAAC;AAC7C,SAAK,GAAG,QAAQ,CAAC,aAAS,0BAAY,IAAI,CAAC;AAC3C,SAAK,GAAG,UAAU,CAAC,aAAS,0BAAY,IAAI,CAAC;AAC7C,SAAK,GAAG,QAAQ,CAAC,aAAS,0BAAY,IAAI,CAAC;AAC3C,SAAK,GAAG,SAAS,CAAC,MAAM,GAAG,gBAAgB;AACzC,UAAI,CAAC,aAAa;AAChB,sCAAY,IAAI;AAAA,MAClB;AAAA,IACF,CAAC;AACD,SAAK,GAAG,WAAW,CAAC,aAAS,0BAAY,MAAM,KAAK,CAAC;AACrD,SAAK,GAAG,qBAAqB,CAAC,MAAM,kBAAc,0BAAY,MAAM,SAAS,CAAC;AAE9E,WAAO;AAAA,EACT;AAAA,EAEO,SAAS,SAAmB;AACjC,SAAK,gBAAgB;AACrB,WAAO;AAAA,EACT;AAAA,EAEO,OAAO,SAAsB;AAClC,SAAK,cAAc;AACnB,WAAO;AAAA,EACT;AAAA,EAEO,iBAAiB,SAAc;AACpC,WAAO,KAAK,cAAc,OAAO,CAAC,MAAM,MAAM,GAAG,QAAQ;AACvD,YAAM,QAAQ,IAAI;AAClB,UAAI,QAAQ,eAAe,KAAK,GAAG;AACjC,YAAI,oBAAoB,QAAQ,KAAY,MAAM,IAAI;AACpD,+BAAO,KAAK,WAAW,uDAAuD;AAAA,QAEhF,OAAO;AACL,eAAK,SAAS,QAAQ;AAAA,QACxB;AAAA,MACF;AACA,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,EACP;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -16,15 +16,16 @@ const INVALID_OPTION_KEYS = [
|
|
|
16
16
|
"roomId"
|
|
17
17
|
];
|
|
18
18
|
class RegisteredHandler extends EventEmitter {
|
|
19
|
-
constructor(klass, options) {
|
|
19
|
+
constructor(name, klass, options) {
|
|
20
20
|
super();
|
|
21
|
+
this.name = name;
|
|
22
|
+
this.klass = klass;
|
|
23
|
+
this.options = options;
|
|
21
24
|
this.filterOptions = [];
|
|
22
25
|
if (typeof klass !== "function") {
|
|
23
26
|
logger.debug("You are likely not importing your room class correctly.");
|
|
24
27
|
throw new Error(`class is expected but ${typeof klass} was provided.`);
|
|
25
28
|
}
|
|
26
|
-
this.klass = klass;
|
|
27
|
-
this.options = options;
|
|
28
29
|
}
|
|
29
30
|
enableRealtimeListing() {
|
|
30
31
|
this.on("create", (room) => updateLobby(room));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/matchmaker/RegisteredHandler.ts"],
|
|
4
|
-
"sourcesContent": ["import { IncomingMessage } from 'http';\nimport { EventEmitter } from 'events';\nimport { logger } from '../Logger';\nimport {
|
|
5
|
-
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AAIvB,SAAS,mBAAmB;AAG5B,IAAI,eAAoB;AACxB,IAAI;AAAE,iBAAe,QAAQ,gBAAgB;AAAG,SAAS,GAAP;AAAW;AAEtD,MAAM,
|
|
4
|
+
"sourcesContent": ["import { IncomingMessage } from 'http';\nimport { EventEmitter } from 'events';\nimport { logger } from '../Logger';\nimport { RoomCache, SortOptions } from './driver/api';\n\nimport { Room } from './../Room';\nimport { updateLobby } from './Lobby';\nimport { Type } from '../utils/types';\n\nlet ColyseusAuth: any = undefined;\ntry { ColyseusAuth = require('@colyseus/auth'); } catch (e) {}\n\nexport const INVALID_OPTION_KEYS: Array<keyof RoomCache> = [\n 'clients',\n 'locked',\n 'private',\n // 'maxClients', - maxClients can be useful as filter options\n 'metadata',\n 'name',\n 'processId',\n 'roomId',\n];\n\nexport type ValidateAuthTokenCallback = (token: string, request?: IncomingMessage) => Promise<any>;\n\nexport class RegisteredHandler extends EventEmitter {\n public filterOptions: string[] = [];\n public sortOptions?: SortOptions;\n\n constructor(\n public name: string,\n public klass: Type<Room>,\n public options: any\n ) {\n super();\n\n if (typeof(klass) !== 'function') {\n logger.debug('You are likely not importing your room class correctly.');\n throw new Error(`class is expected but ${typeof(klass)} was provided.`);\n }\n }\n\n public enableRealtimeListing() {\n this.on('create', (room) => updateLobby(room));\n this.on('lock', (room) => updateLobby(room));\n this.on('unlock', (room) => updateLobby(room));\n this.on('join', (room) => updateLobby(room));\n this.on('leave', (room, _, willDispose) => {\n if (!willDispose) {\n updateLobby(room);\n }\n });\n this.on('dispose', (room) => updateLobby(room, false));\n this.on('visibility-change', (room, isVisible) => updateLobby(room, isVisible));\n\n return this;\n }\n\n public filterBy(options: string[]) {\n this.filterOptions = options;\n return this;\n }\n\n public sortBy(options: SortOptions) {\n this.sortOptions = options;\n return this;\n }\n\n public getFilterOptions(options: any) {\n return this.filterOptions.reduce((prev, curr, i, arr) => {\n const field = arr[i];\n if (options.hasOwnProperty(field)) {\n if (INVALID_OPTION_KEYS.indexOf(field as any) !== -1) {\n logger.warn(`option \"${field}\" has internal usage and is going to be ignored.`);\n\n } else {\n prev[field] = options[field];\n }\n }\n return prev;\n }, {});\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AAIvB,SAAS,mBAAmB;AAG5B,IAAI,eAAoB;AACxB,IAAI;AAAE,iBAAe,QAAQ,gBAAgB;AAAG,SAAS,GAAP;AAAW;AAEtD,MAAM,sBAA8C;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,MAAM,0BAA0B,aAAa;AAAA,EAIlD,YACS,MACA,OACA,SACP;AACA,UAAM;AAJC;AACA;AACA;AANT,SAAO,gBAA0B,CAAC;AAUhC,QAAI,OAAO,UAAW,YAAY;AAChC,aAAO,MAAM,yDAAyD;AACtE,YAAM,IAAI,MAAM,yBAAyB,OAAO,qBAAsB;AAAA,IACxE;AAAA,EACF;AAAA,EAEO,wBAAwB;AAC7B,SAAK,GAAG,UAAU,CAAC,SAAS,YAAY,IAAI,CAAC;AAC7C,SAAK,GAAG,QAAQ,CAAC,SAAS,YAAY,IAAI,CAAC;AAC3C,SAAK,GAAG,UAAU,CAAC,SAAS,YAAY,IAAI,CAAC;AAC7C,SAAK,GAAG,QAAQ,CAAC,SAAS,YAAY,IAAI,CAAC;AAC3C,SAAK,GAAG,SAAS,CAAC,MAAM,GAAG,gBAAgB;AACzC,UAAI,CAAC,aAAa;AAChB,oBAAY,IAAI;AAAA,MAClB;AAAA,IACF,CAAC;AACD,SAAK,GAAG,WAAW,CAAC,SAAS,YAAY,MAAM,KAAK,CAAC;AACrD,SAAK,GAAG,qBAAqB,CAAC,MAAM,cAAc,YAAY,MAAM,SAAS,CAAC;AAE9E,WAAO;AAAA,EACT;AAAA,EAEO,SAAS,SAAmB;AACjC,SAAK,gBAAgB;AACrB,WAAO;AAAA,EACT;AAAA,EAEO,OAAO,SAAsB;AAClC,SAAK,cAAc;AACnB,WAAO;AAAA,EACT;AAAA,EAEO,iBAAiB,SAAc;AACpC,WAAO,KAAK,cAAc,OAAO,CAAC,MAAM,MAAM,GAAG,QAAQ;AACvD,YAAM,QAAQ,IAAI;AAClB,UAAI,QAAQ,eAAe,KAAK,GAAG;AACjC,YAAI,oBAAoB,QAAQ,KAAY,MAAM,IAAI;AACpD,iBAAO,KAAK,WAAW,uDAAuD;AAAA,QAEhF,OAAO;AACL,eAAK,SAAS,QAAQ;AAAA,QACxB;AAAA,MACF;AACA,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,EACP;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Matchmaking controller
|
|
3
3
|
* (for interoperability between different http frameworks, e.g. express, uWebSockets.js, etc)
|
|
4
4
|
*/
|
|
5
|
-
/// <reference types="node" />
|
|
6
5
|
import { IncomingMessage } from "http";
|
|
7
6
|
import * as matchMaker from "../MatchMaker";
|
|
8
7
|
declare const _default: {
|
|
@@ -33,7 +32,7 @@ declare const _default: {
|
|
|
33
32
|
getCorsHeaders(req: IncomingMessage): {
|
|
34
33
|
[header: string]: string;
|
|
35
34
|
};
|
|
36
|
-
getAvailableRooms(roomName: string): Promise<import("
|
|
35
|
+
getAvailableRooms(roomName: string): Promise<import("..").IRoomCache[]>;
|
|
37
36
|
invokeMethod(method: string, roomName: string, clientOptions?: matchMaker.ClientOptions, authOptions?: matchMaker.AuthOptions): Promise<any>;
|
|
38
37
|
};
|
|
39
38
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class
|
|
1
|
+
import { RoomCache, IRoomCache } from './interfaces';
|
|
2
|
+
export declare class RoomData implements RoomCache {
|
|
3
3
|
clients: number;
|
|
4
4
|
locked: boolean;
|
|
5
5
|
private: boolean;
|
|
@@ -12,7 +12,7 @@ export declare class RoomCache implements RoomListingData {
|
|
|
12
12
|
createdAt: Date;
|
|
13
13
|
unlisted: boolean;
|
|
14
14
|
private $rooms;
|
|
15
|
-
constructor(initialValues: any, rooms:
|
|
15
|
+
constructor(initialValues: any, rooms: IRoomCache[]);
|
|
16
16
|
save(): void;
|
|
17
17
|
updateOne(operations: any): void;
|
|
18
18
|
remove(): void;
|
|
@@ -17,11 +17,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var RoomData_exports = {};
|
|
19
19
|
__export(RoomData_exports, {
|
|
20
|
-
|
|
20
|
+
RoomData: () => RoomData
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(RoomData_exports);
|
|
23
23
|
var import_Utils = require("../../utils/Utils");
|
|
24
|
-
class
|
|
24
|
+
class RoomData {
|
|
25
25
|
constructor(initialValues, rooms) {
|
|
26
26
|
this.clients = 0;
|
|
27
27
|
this.locked = false;
|
|
@@ -75,5 +75,5 @@ class RoomCache {
|
|
|
75
75
|
}
|
|
76
76
|
// Annotate the CommonJS export names for ESM import in node:
|
|
77
77
|
0 && (module.exports = {
|
|
78
|
-
|
|
78
|
+
RoomData
|
|
79
79
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/matchmaker/driver/RoomData.ts"],
|
|
4
|
-
"sourcesContent": ["import { spliceOne } from '../../utils/Utils';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAGnB,MAAM,
|
|
4
|
+
"sourcesContent": ["import { spliceOne } from '../../utils/Utils';\nimport { RoomCache, IRoomCache } from './interfaces';\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,IAAI,KAAK;AAE1B,eAAW,SAAS,eAAe;AACjC,UAAI,cAAc,eAAe,KAAK,GAAG;AACvC,aAAK,SAAS,cAAc;AAAA,MAC9B;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,SAAS,WAAW,KAAK;AAAA,QAChC;AAAA,MACF;AAAA,IACF;AAEA,QAAI,WAAW,MAAM;AACnB,iBAAW,SAAS,WAAW,MAAM;AACnC,YAAI,WAAW,KAAK,eAAe,KAAK,GAAG;AACzC,eAAK,UAAU,WAAW,KAAK;AAAA,QACjC;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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spliceOne } from "../../utils/Utils";
|
|
2
|
-
class
|
|
2
|
+
class RoomData {
|
|
3
3
|
constructor(initialValues, rooms) {
|
|
4
4
|
this.clients = 0;
|
|
5
5
|
this.locked = false;
|
|
@@ -52,5 +52,5 @@ class RoomCache {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
export {
|
|
55
|
-
|
|
55
|
+
RoomData
|
|
56
56
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/matchmaker/driver/RoomData.ts"],
|
|
4
|
-
"sourcesContent": ["import { spliceOne } from '../../utils/Utils';\nimport {
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,
|
|
4
|
+
"sourcesContent": ["import { spliceOne } from '../../utils/Utils';\nimport { RoomCache, IRoomCache } from './interfaces';\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,SAAS,iBAAiB;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,IAAI,KAAK;AAE1B,eAAW,SAAS,eAAe;AACjC,UAAI,cAAc,eAAe,KAAK,GAAG;AACvC,aAAK,SAAS,cAAc;AAAA,MAC9B;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,SAAS,WAAW,KAAK;AAAA,QAChC;AAAA,MACF;AAAA,IACF;AAEA,QAAI,WAAW,MAAM;AACnB,iBAAW,SAAS,WAAW,MAAM;AACnC,YAAI,WAAW,KAAK,eAAe,KAAK,GAAG;AACzC,eAAK,UAAU,WAAW,KAAK;AAAA,QACjC;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,cAAU,KAAK,QAAQ,SAAS;AAChC,SAAK,SAAS;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export interface SortOptions {
|
|
2
|
+
[fieldName: string]: 1 | -1 | 'asc' | 'desc' | 'ascending' | 'descending';
|
|
3
|
+
}
|
|
4
|
+
export declare function getLockId(filterOptions: any): string;
|
|
5
|
+
export interface IRoomCache {
|
|
6
|
+
/**
|
|
7
|
+
* Unique identifier for the room.
|
|
8
|
+
*/
|
|
9
|
+
roomId: string;
|
|
10
|
+
/**
|
|
11
|
+
* Number of clients connected to this room.
|
|
12
|
+
*/
|
|
13
|
+
clients: number;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of clients allowed to join the room.
|
|
16
|
+
*/
|
|
17
|
+
maxClients: number;
|
|
18
|
+
/**
|
|
19
|
+
* Indicates if the room is locked (i.e. join requests are rejected).
|
|
20
|
+
*/
|
|
21
|
+
locked: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Indicates if the room is private
|
|
24
|
+
* Private rooms can't be joined via `join()` or `joinOrCreate()`.
|
|
25
|
+
*/
|
|
26
|
+
private: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Room name.
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
/**
|
|
32
|
+
* Public address of the server.
|
|
33
|
+
*/
|
|
34
|
+
publicAddress?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Process id where the room is running.
|
|
37
|
+
*/
|
|
38
|
+
processId: string;
|
|
39
|
+
/**
|
|
40
|
+
* Do not show this room in lobby listing.
|
|
41
|
+
*/
|
|
42
|
+
unlisted: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Metadata associated with the room.
|
|
45
|
+
*/
|
|
46
|
+
metadata: any;
|
|
47
|
+
/**
|
|
48
|
+
* Additional custom properties
|
|
49
|
+
*/
|
|
50
|
+
[property: string]: any;
|
|
51
|
+
}
|
|
52
|
+
export interface RoomCache<Metadata = any> extends IRoomCache {
|
|
53
|
+
metadata: Metadata;
|
|
54
|
+
updateOne(operations: any): any;
|
|
55
|
+
save(): any;
|
|
56
|
+
remove(): any;
|
|
57
|
+
}
|
|
58
|
+
export interface MatchMakerDriver {
|
|
59
|
+
/**
|
|
60
|
+
* Initialize a room cache which contains CRUD operations for room listings.
|
|
61
|
+
*
|
|
62
|
+
* @param initialValues - Predefined room properties.
|
|
63
|
+
*
|
|
64
|
+
* @returns RoomData - New room cache.
|
|
65
|
+
*/
|
|
66
|
+
createInstance(initialValues: Partial<IRoomCache>): RoomCache;
|
|
67
|
+
/**
|
|
68
|
+
* Check if a room exists in room cache.
|
|
69
|
+
*
|
|
70
|
+
* @param roomId - The room id.
|
|
71
|
+
*
|
|
72
|
+
* @returns Promise<boolean> | boolean - A promise or a boolean value indicating if the room exists.
|
|
73
|
+
*/
|
|
74
|
+
has(roomId: string): Promise<boolean> | boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Query rooms in room cache for given conditions.
|
|
77
|
+
*
|
|
78
|
+
* @param conditions - Filtering conditions.
|
|
79
|
+
*
|
|
80
|
+
* @returns Promise<IRoomCache[]> | IRoomCache[] - A promise or an object contaning room metadata list.
|
|
81
|
+
*/
|
|
82
|
+
query(conditions: Partial<IRoomCache>, sortOptions?: SortOptions): Promise<IRoomCache[]> | IRoomCache[];
|
|
83
|
+
/**
|
|
84
|
+
* Clean up rooms in room cache by process id.
|
|
85
|
+
* @param processId - The process id.
|
|
86
|
+
*/
|
|
87
|
+
cleanup?(processId: string): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Query for a room in room cache for given conditions.
|
|
90
|
+
*
|
|
91
|
+
* @param conditions - Filtering conditions.
|
|
92
|
+
*
|
|
93
|
+
* @returns `IRoomCache` - An object contaning filtered room metadata.
|
|
94
|
+
*/
|
|
95
|
+
findOne(conditions: Partial<IRoomCache>, sortOptions?: SortOptions): Promise<RoomCache>;
|
|
96
|
+
/**
|
|
97
|
+
* Empty the room cache.
|
|
98
|
+
*/
|
|
99
|
+
clear(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Dispose the connection of the room cache medium.
|
|
102
|
+
*/
|
|
103
|
+
shutdown(): void;
|
|
104
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 api_exports = {};
|
|
19
|
+
__export(api_exports, {
|
|
20
|
+
getLockId: () => getLockId
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(api_exports);
|
|
23
|
+
function getLockId(filterOptions) {
|
|
24
|
+
return Object.keys(filterOptions).map((key) => `${key}:${filterOptions[key]}`).join("-");
|
|
25
|
+
}
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
getLockId
|
|
29
|
+
});
|
|
@@ -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,OAAO,cAAc,MAAM,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,OAAO,cAAc,MAAM,EAAE,KAAK,GAAG;AACzF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type {
|
|
3
|
-
import {
|
|
1
|
+
import { IRoomCache, SortOptions, RoomCache, QueryHelpers, MatchMakerDriver } from "./interfaces";
|
|
2
|
+
export type { IRoomCache, SortOptions, RoomCache, QueryHelpers, MatchMakerDriver };
|
|
3
|
+
import { RoomData } from './RoomData';
|
|
4
4
|
export declare class LocalDriver implements MatchMakerDriver {
|
|
5
|
-
rooms:
|
|
6
|
-
createInstance(initialValues?: any):
|
|
5
|
+
rooms: IRoomCache[];
|
|
6
|
+
createInstance(initialValues?: any): RoomData;
|
|
7
7
|
has(roomId: string): boolean;
|
|
8
|
-
find(conditions: Partial<
|
|
8
|
+
find(conditions: Partial<IRoomCache>): IRoomCache[];
|
|
9
9
|
cleanup(processId: string): Promise<void>;
|
|
10
|
-
findOne(conditions: Partial<
|
|
10
|
+
findOne(conditions: Partial<IRoomCache>): QueryHelpers<RoomCache>;
|
|
11
11
|
clear(): void;
|
|
12
12
|
shutdown(): void;
|
|
13
13
|
}
|
|
@@ -28,7 +28,7 @@ class LocalDriver {
|
|
|
28
28
|
this.rooms = [];
|
|
29
29
|
}
|
|
30
30
|
createInstance(initialValues = {}) {
|
|
31
|
-
return new import_RoomData.
|
|
31
|
+
return new import_RoomData.RoomData(initialValues, this.rooms);
|
|
32
32
|
}
|
|
33
33
|
has(roomId) {
|
|
34
34
|
return this.rooms.some((room) => room.roomId === roomId);
|
|
@@ -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 {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AAMvB,mBAAsB;AACtB,
|
|
4
|
+
"sourcesContent": ["import { logger } from \"../../Logger\";\nimport { IRoomCache, SortOptions, RoomCache, QueryHelpers, MatchMakerDriver } from \"./interfaces\";\n\n// re-export\nexport type { IRoomCache, SortOptions, RoomCache, QueryHelpers, MatchMakerDriver };\n\nimport { Query } from './Query';\nimport { RoomData } from './RoomData';\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 find(conditions: Partial<IRoomCache>) {\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 logger.debug(\"> Removing stale rooms by processId:\", processId, `(${cachedRooms.length} rooms found)`);\n\n cachedRooms.forEach((room) => room.remove());\n return Promise.resolve();\n }\n\n public findOne(conditions: Partial<IRoomCache>) {\n return new Query<RoomCache>(this.rooms, conditions) as any as QueryHelpers<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,oBAAuB;AAMvB,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,KAAK,YAAiC;AAC3C,WAAO,KAAK,MAAM,OAAQ,CAAC,SAAS;AAClC,iBAAW,SAAS,YAAY;AAC9B,YACE,WAAW,eAAe,KAAK,KAC/B,KAAK,WAAW,WAAW,QAC3B;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,yBAAO,MAAM,wCAAwC,WAAW,IAAI,YAAY,qBAAqB;AAErG,gBAAY,QAAQ,CAAC,SAAS,KAAK,OAAO,CAAC;AAC3C,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,QAAQ,YAAiC;AAC9C,WAAO,IAAI,mBAAiB,KAAK,OAAO,UAAU;AAAA,EACpD;AAAA,EAEO,QAAQ;AACb,SAAK,QAAQ,CAAC;AAAA,EAChB;AAAA,EAEO,WAAW;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { logger } from "../../Logger";
|
|
2
2
|
import { Query } from "./Query";
|
|
3
|
-
import {
|
|
3
|
+
import { RoomData } from "./RoomData";
|
|
4
4
|
class LocalDriver {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.rooms = [];
|
|
7
7
|
}
|
|
8
8
|
createInstance(initialValues = {}) {
|
|
9
|
-
return new
|
|
9
|
+
return new RoomData(initialValues, this.rooms);
|
|
10
10
|
}
|
|
11
11
|
has(roomId) {
|
|
12
12
|
return this.rooms.some((room) => room.roomId === roomId);
|
|
@@ -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 {
|
|
5
|
-
"mappings": "AAAA,SAAS,cAAc;AAMvB,SAAS,aAAa;AACtB,SAAS,
|
|
4
|
+
"sourcesContent": ["import { logger } from \"../../Logger\";\nimport { IRoomCache, SortOptions, RoomCache, QueryHelpers, MatchMakerDriver } from \"./interfaces\";\n\n// re-export\nexport type { IRoomCache, SortOptions, RoomCache, QueryHelpers, MatchMakerDriver };\n\nimport { Query } from './Query';\nimport { RoomData } from './RoomData';\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 find(conditions: Partial<IRoomCache>) {\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 logger.debug(\"> Removing stale rooms by processId:\", processId, `(${cachedRooms.length} rooms found)`);\n\n cachedRooms.forEach((room) => room.remove());\n return Promise.resolve();\n }\n\n public findOne(conditions: Partial<IRoomCache>) {\n return new Query<RoomCache>(this.rooms, conditions) as any as QueryHelpers<RoomCache>;\n }\n\n public clear() {\n this.rooms = [];\n }\n\n public shutdown() {\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAMvB,SAAS,aAAa;AACtB,SAAS,gBAAgB;AAElB,MAAM,YAAwC;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,KAAK,YAAiC;AAC3C,WAAO,KAAK,MAAM,OAAQ,CAAC,SAAS;AAClC,iBAAW,SAAS,YAAY;AAC9B,YACE,WAAW,eAAe,KAAK,KAC/B,KAAK,WAAW,WAAW,QAC3B;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,WAAO,MAAM,wCAAwC,WAAW,IAAI,YAAY,qBAAqB;AAErG,gBAAY,QAAQ,CAAC,SAAS,KAAK,OAAO,CAAC;AAC3C,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,QAAQ,YAAiC;AAC9C,WAAO,IAAI,MAAiB,KAAK,OAAO,UAAU;AAAA,EACpD;AAAA,EAEO,QAAQ;AACb,SAAK,QAAQ,CAAC;AAAA,EAChB;AAAA,EAEO,WAAW;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface SortOptions {
|
|
2
2
|
[fieldName: string]: 1 | -1 | 'asc' | 'desc' | 'ascending' | 'descending';
|
|
3
3
|
}
|
|
4
|
-
export interface
|
|
4
|
+
export interface IRoomCache {
|
|
5
5
|
clients: number;
|
|
6
6
|
locked: boolean;
|
|
7
7
|
private: boolean;
|
|
@@ -14,16 +14,12 @@ export interface IRoomListingData {
|
|
|
14
14
|
unlisted: boolean;
|
|
15
15
|
[property: string]: any;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
17
|
+
export interface RoomCache<Metadata = any> extends IRoomCache {
|
|
18
18
|
metadata: Metadata;
|
|
19
19
|
updateOne(operations: any): any;
|
|
20
20
|
save(): any;
|
|
21
21
|
remove(): any;
|
|
22
22
|
}
|
|
23
|
-
export interface QueryHelpers<T> {
|
|
24
|
-
then: Promise<T>['then'];
|
|
25
|
-
sort(options: SortOptions): any;
|
|
26
|
-
}
|
|
27
23
|
export interface MatchMakerDriver {
|
|
28
24
|
/**
|
|
29
25
|
* Initialize a room cache which contains CRUD operations for room listings.
|
|
@@ -32,7 +28,7 @@ export interface MatchMakerDriver {
|
|
|
32
28
|
*
|
|
33
29
|
* @returns RoomData - New room cache.
|
|
34
30
|
*/
|
|
35
|
-
createInstance(initialValues: Partial<
|
|
31
|
+
createInstance(initialValues: Partial<IRoomCache>): RoomCache;
|
|
36
32
|
/**
|
|
37
33
|
* Check if a room exists in room cache.
|
|
38
34
|
*
|
|
@@ -46,9 +42,9 @@ export interface MatchMakerDriver {
|
|
|
46
42
|
*
|
|
47
43
|
* @param conditions - Filtering conditions.
|
|
48
44
|
*
|
|
49
|
-
* @returns Promise<
|
|
45
|
+
* @returns Promise<IRoomCache[]> | IRoomCache[] - A promise or an object contaning room metadata list.
|
|
50
46
|
*/
|
|
51
|
-
|
|
47
|
+
query(conditions: Partial<IRoomCache>, sortOptions?: SortOptions): Promise<IRoomCache[]> | IRoomCache[];
|
|
52
48
|
/**
|
|
53
49
|
* Clean up rooms in room cache by process id.
|
|
54
50
|
* @param processId - The process id.
|
|
@@ -59,9 +55,9 @@ export interface MatchMakerDriver {
|
|
|
59
55
|
*
|
|
60
56
|
* @param conditions - Filtering conditions.
|
|
61
57
|
*
|
|
62
|
-
* @returns `
|
|
58
|
+
* @returns `IRoomCache` - An object contaning filtered room metadata.
|
|
63
59
|
*/
|
|
64
|
-
findOne(conditions: Partial<
|
|
60
|
+
findOne(conditions: Partial<IRoomCache>, sortOptions?: SortOptions): Promise<RoomCache>;
|
|
65
61
|
/**
|
|
66
62
|
* Empty the room cache.
|
|
67
63
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/matchmaker/driver/interfaces.ts"],
|
|
4
|
-
"sourcesContent": ["export interface SortOptions {
|
|
4
|
+
"sourcesContent": ["export interface SortOptions {\n [fieldName: string]: 1 | -1 | 'asc' | 'desc' | 'ascending' | 'descending';\n}\n\nexport interface IRoomCache {\n clients: number;\n locked: boolean;\n private: boolean;\n maxClients: number;\n metadata: any;\n name: string;\n publicAddress?: string;\n processId: string;\n roomId: string;\n unlisted: boolean;\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 /**\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"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IRoomCache, SortOptions, RoomCache, MatchMakerDriver } from "../api";
|
|
2
|
+
export type { IRoomCache, SortOptions, RoomCache, MatchMakerDriver };
|
|
3
|
+
import { RoomData } from './RoomData';
|
|
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
|
+
}
|