@colyseus/core 0.16.0-preview.3 → 0.16.0-preview.31
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/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 +30 -22
- package/build/MatchMaker.js +110 -87
- package/build/MatchMaker.js.map +2 -2
- package/build/MatchMaker.mjs +114 -94
- package/build/MatchMaker.mjs.map +2 -2
- package/build/Protocol.d.ts +3 -4
- package/build/Protocol.js +28 -19
- package/build/Protocol.js.map +2 -2
- package/build/Protocol.mjs +31 -21
- package/build/Protocol.mjs.map +2 -2
- package/build/Room.d.ts +36 -35
- package/build/Room.js +270 -109
- package/build/Room.js.map +2 -2
- package/build/Room.mjs +274 -116
- package/build/Room.mjs.map +2 -2
- package/build/Server.d.ts +6 -7
- package/build/Server.js +40 -12
- package/build/Server.js.map +2 -2
- package/build/Server.mjs +40 -15
- package/build/Server.mjs.map +3 -3
- package/build/Stats.js +1 -1
- package/build/Stats.js.map +2 -2
- package/build/Stats.mjs +6 -5
- package/build/Stats.mjs.map +2 -2
- package/build/Transport.d.ts +24 -11
- 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/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 +20 -19
- package/build/index.js +28 -20
- package/build/index.js.map +2 -2
- package/build/index.mjs +21 -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 +3 -4
- package/build/matchmaker/controller.js +22 -5
- package/build/matchmaker/controller.js.map +2 -2
- package/build/matchmaker/controller.mjs +19 -3
- package/build/matchmaker/controller.mjs.map +2 -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 +7 -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 +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 -3
- package/build/presence/LocalPresence.js +83 -5
- package/build/presence/LocalPresence.js.map +3 -3
- package/build/presence/LocalPresence.mjs +83 -8
- 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 +2 -2
- 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 +13 -11
- package/build/serializer/SchemaSerializer.js +13 -10
- package/build/serializer/SchemaSerializer.js.map +2 -2
- package/build/serializer/SchemaSerializer.mjs +17 -13
- package/build/serializer/SchemaSerializer.mjs.map +2 -2
- 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 +4 -2
- package/build/utils/Utils.js +16 -15
- package/build/utils/Utils.js.map +2 -2
- package/build/utils/Utils.mjs +18 -21
- package/build/utils/Utils.mjs.map +2 -2
- package/package.json +9 -3
package/build/Debug.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -34,8 +38,8 @@ __export(Debug_exports, {
|
|
|
34
38
|
});
|
|
35
39
|
module.exports = __toCommonJS(Debug_exports);
|
|
36
40
|
var import_debug = __toESM(require("debug"));
|
|
37
|
-
var import_Logger = require("./Logger");
|
|
38
|
-
var import_ServerError = require("./errors/ServerError");
|
|
41
|
+
var import_Logger = require("./Logger.js");
|
|
42
|
+
var import_ServerError = require("./errors/ServerError.js");
|
|
39
43
|
const debugConnection = (0, import_debug.default)("colyseus:connection");
|
|
40
44
|
const debugDriver = (0, import_debug.default)("colyseus:driver");
|
|
41
45
|
const debugError = (0, import_debug.default)("colyseus:errors");
|
package/build/Debug.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/Debug.ts"],
|
|
4
|
-
"sourcesContent": ["import debug from 'debug';\nimport { logger } from './Logger';\nimport { ServerError } from './errors/ServerError';\n\nexport const debugConnection = debug('colyseus:connection');\nexport const debugDriver = debug('colyseus:driver');\nexport const debugError = debug('colyseus:errors');\nexport const debugMatchMaking = debug('colyseus:matchmaking');\nexport const debugMessage = debug('colyseus:message');\nexport const debugPatch = debug('colyseus:patch');\nexport const debugPresence = debug('colyseus:presence');\n\nexport const debugAndPrintError = (e: Error | string) => {\n const message = (e instanceof Error) ? e.stack : e;\n\n if (!(e instanceof ServerError)) {\n logger.error(message);\n }\n\n debugError.call(debugError, message);\n};\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import debug from 'debug';\nimport { logger } from './Logger.js';\nimport { ServerError } from './errors/ServerError.js';\n\nexport const debugConnection = debug('colyseus:connection');\nexport const debugDriver = debug('colyseus:driver');\nexport const debugError = debug('colyseus:errors');\nexport const debugMatchMaking = debug('colyseus:matchmaking');\nexport const debugMessage = debug('colyseus:message');\nexport const debugPatch = debug('colyseus:patch');\nexport const debugPresence = debug('colyseus:presence');\n\nexport const debugAndPrintError = (e: Error | string) => {\n const message = (e instanceof Error) ? e.stack : e;\n\n if (!(e instanceof ServerError)) {\n logger.error(message);\n }\n\n debugError.call(debugError, message);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,oBAAuB;AACvB,yBAA4B;AAErB,MAAM,sBAAkB,aAAAA,SAAM,qBAAqB;AACnD,MAAM,kBAAc,aAAAA,SAAM,iBAAiB;AAC3C,MAAM,iBAAa,aAAAA,SAAM,iBAAiB;AAC1C,MAAM,uBAAmB,aAAAA,SAAM,sBAAsB;AACrD,MAAM,mBAAe,aAAAA,SAAM,kBAAkB;AAC7C,MAAM,iBAAa,aAAAA,SAAM,gBAAgB;AACzC,MAAM,oBAAgB,aAAAA,SAAM,mBAAmB;AAE/C,MAAM,qBAAqB,CAAC,MAAsB;AACvD,QAAM,UAAW,aAAa,QAAS,EAAE,QAAQ;AAEjD,MAAI,EAAE,aAAa,iCAAc;AAC/B,yBAAO,MAAM,OAAO;AAAA,EACtB;AAEA,aAAW,KAAK,YAAY,OAAO;AACrC;",
|
|
6
6
|
"names": ["debug"]
|
|
7
7
|
}
|
package/build/Debug.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
// packages/core/src/Debug.ts
|
|
1
2
|
import debug from "debug";
|
|
2
|
-
import { logger } from "./Logger";
|
|
3
|
-
import { ServerError } from "./errors/ServerError";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
import { logger } from "./Logger.mjs";
|
|
4
|
+
import { ServerError } from "./errors/ServerError.mjs";
|
|
5
|
+
var debugConnection = debug("colyseus:connection");
|
|
6
|
+
var debugDriver = debug("colyseus:driver");
|
|
7
|
+
var debugError = debug("colyseus:errors");
|
|
8
|
+
var debugMatchMaking = debug("colyseus:matchmaking");
|
|
9
|
+
var debugMessage = debug("colyseus:message");
|
|
10
|
+
var debugPatch = debug("colyseus:patch");
|
|
11
|
+
var debugPresence = debug("colyseus:presence");
|
|
12
|
+
var debugAndPrintError = (e) => {
|
|
12
13
|
const message = e instanceof Error ? e.stack : e;
|
|
13
14
|
if (!(e instanceof ServerError)) {
|
|
14
15
|
logger.error(message);
|
package/build/Debug.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/Debug.ts"],
|
|
4
|
-
"sourcesContent": ["import debug from 'debug';\nimport { logger } from './Logger';\nimport { ServerError } from './errors/ServerError';\n\nexport const debugConnection = debug('colyseus:connection');\nexport const debugDriver = debug('colyseus:driver');\nexport const debugError = debug('colyseus:errors');\nexport const debugMatchMaking = debug('colyseus:matchmaking');\nexport const debugMessage = debug('colyseus:message');\nexport const debugPatch = debug('colyseus:patch');\nexport const debugPresence = debug('colyseus:presence');\n\nexport const debugAndPrintError = (e: Error | string) => {\n const message = (e instanceof Error) ? e.stack : e;\n\n if (!(e instanceof ServerError)) {\n logger.error(message);\n }\n\n debugError.call(debugError, message);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAErB,
|
|
4
|
+
"sourcesContent": ["import debug from 'debug';\nimport { logger } from './Logger.js';\nimport { ServerError } from './errors/ServerError.js';\n\nexport const debugConnection = debug('colyseus:connection');\nexport const debugDriver = debug('colyseus:driver');\nexport const debugError = debug('colyseus:errors');\nexport const debugMatchMaking = debug('colyseus:matchmaking');\nexport const debugMessage = debug('colyseus:message');\nexport const debugPatch = debug('colyseus:patch');\nexport const debugPresence = debug('colyseus:presence');\n\nexport const debugAndPrintError = (e: Error | string) => {\n const message = (e instanceof Error) ? e.stack : e;\n\n if (!(e instanceof ServerError)) {\n logger.error(message);\n }\n\n debugError.call(debugError, message);\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,WAAW;AAClB,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAErB,IAAM,kBAAkB,MAAM,qBAAqB;AACnD,IAAM,cAAc,MAAM,iBAAiB;AAC3C,IAAM,aAAa,MAAM,iBAAiB;AAC1C,IAAM,mBAAmB,MAAM,sBAAsB;AACrD,IAAM,eAAe,MAAM,kBAAkB;AAC7C,IAAM,aAAa,MAAM,gBAAgB;AACzC,IAAM,gBAAgB,MAAM,mBAAmB;AAE/C,IAAM,qBAAqB,CAAC,MAAsB;AACvD,QAAM,UAAW,aAAa,QAAS,EAAE,QAAQ;AAEjD,MAAI,EAAE,aAAa,cAAc;AAC/B,WAAO,MAAM,OAAO;AAAA,EACtB;AAEA,aAAW,KAAK,YAAY,OAAO;AACrC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/IPC.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Presence } from './presence/Presence';
|
|
1
|
+
import { Presence } from './presence/Presence.js';
|
|
2
2
|
export declare function requestFromIPC<T>(presence: Presence, publishToChannel: string, method: string, args: any[], rejectionTimeout?: number): Promise<T>;
|
|
3
3
|
export declare function subscribeIPC(presence: Presence, processId: string, channel: string, replyCallback: (method: string, args: any[]) => any): Promise<void>;
|
package/build/IPC.js
CHANGED
|
@@ -21,9 +21,9 @@ __export(IPC_exports, {
|
|
|
21
21
|
subscribeIPC: () => subscribeIPC
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(IPC_exports);
|
|
24
|
-
var import_Debug = require("./Debug");
|
|
25
|
-
var import_Protocol = require("./Protocol");
|
|
26
|
-
var import_Utils = require("./utils/Utils");
|
|
24
|
+
var import_Debug = require("./Debug.js");
|
|
25
|
+
var import_Protocol = require("./Protocol.js");
|
|
26
|
+
var import_Utils = require("./utils/Utils.js");
|
|
27
27
|
async function requestFromIPC(presence, publishToChannel, method, args, rejectionTimeout = import_Utils.REMOTE_ROOM_SHORT_TIMEOUT) {
|
|
28
28
|
return new Promise((resolve, reject) => {
|
|
29
29
|
let unsubscribeTimeout;
|
package/build/IPC.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/IPC.ts"],
|
|
4
|
-
"sourcesContent": ["import { debugAndPrintError } from './Debug';\nimport { Presence } from './presence/Presence';\nimport { IpcProtocol } from './Protocol';\nimport { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from './utils/Utils';\n\nexport async function requestFromIPC<T>(\n presence: Presence,\n publishToChannel: string,\n method: string,\n args: any[],\n rejectionTimeout: number = REMOTE_ROOM_SHORT_TIMEOUT,\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n let unsubscribeTimeout: NodeJS.Timeout;\n\n const requestId = generateId();\n const channel = `ipc:${requestId}`;\n\n const unsubscribe = () => {\n presence.unsubscribe(channel);\n clearTimeout(unsubscribeTimeout);\n };\n\n presence.subscribe(channel, (message) => {\n const [code, data] = message;\n if (code === IpcProtocol.SUCCESS) {\n resolve(data);\n\n } else if (code === IpcProtocol.ERROR) {\n let error: any = data;\n\n // parse error message + code\n try { error = JSON.parse(data) } catch (e) {}\n\n // turn string message into Error instance\n if (typeof(error) === \"string\") {\n error = new Error(error);\n }\n\n reject(error);\n }\n unsubscribe();\n });\n\n presence.publish(publishToChannel, [method, requestId, args]);\n\n unsubscribeTimeout = setTimeout(() => {\n unsubscribe();\n reject(new Error(\"ipc_timeout\"));\n }, rejectionTimeout);\n });\n}\n\nexport async function subscribeIPC(\n presence: Presence,\n processId: string,\n channel: string,\n replyCallback: (method: string, args: any[]) => any,\n) {\n await presence.subscribe(channel, (message) => {\n const [method, requestId, args] = message;\n\n const reply = (code, data) => {\n presence.publish(`ipc:${requestId}`, [code, data]);\n };\n\n // reply with method result\n let response: any;\n try {\n response = replyCallback(method, args);\n\n } catch (e) {\n debugAndPrintError(e);\n const error = (typeof(e.code) !== \"undefined\")\n ? { code: e.code, message: e.message }\n : e.message;\n return reply(IpcProtocol.ERROR, JSON.stringify(error));\n }\n\n if (!(response instanceof Promise)) {\n return reply(IpcProtocol.SUCCESS, response);\n }\n\n response.\n then((result) => reply(IpcProtocol.SUCCESS, result)).\n catch((e) => {\n // user might have called `reject()` without arguments.\n const err = e && e.message || e;\n reply(IpcProtocol.ERROR, err);\n });\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmC;AAEnC,sBAA4B;AAC5B,mBAAsD;AAEtD,eAAsB,eACpB,UACA,kBACA,QACA,MACA,mBAA2B,wCACf;AACZ,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI;AAEJ,UAAM,gBAAY,yBAAW;AAC7B,UAAM,UAAU,OAAO;
|
|
4
|
+
"sourcesContent": ["import { debugAndPrintError } from './Debug.js';\nimport { Presence } from './presence/Presence.js';\nimport { IpcProtocol } from './Protocol.js';\nimport { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from './utils/Utils.js';\n\nexport async function requestFromIPC<T>(\n presence: Presence,\n publishToChannel: string,\n method: string,\n args: any[],\n rejectionTimeout: number = REMOTE_ROOM_SHORT_TIMEOUT,\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n let unsubscribeTimeout: NodeJS.Timeout;\n\n const requestId = generateId();\n const channel = `ipc:${requestId}`;\n\n const unsubscribe = () => {\n presence.unsubscribe(channel);\n clearTimeout(unsubscribeTimeout);\n };\n\n presence.subscribe(channel, (message) => {\n const [code, data] = message;\n if (code === IpcProtocol.SUCCESS) {\n resolve(data);\n\n } else if (code === IpcProtocol.ERROR) {\n let error: any = data;\n\n // parse error message + code\n try { error = JSON.parse(data) } catch (e) {}\n\n // turn string message into Error instance\n if (typeof(error) === \"string\") {\n error = new Error(error);\n }\n\n reject(error);\n }\n unsubscribe();\n });\n\n presence.publish(publishToChannel, [method, requestId, args]);\n\n unsubscribeTimeout = setTimeout(() => {\n unsubscribe();\n reject(new Error(\"ipc_timeout\"));\n }, rejectionTimeout);\n });\n}\n\nexport async function subscribeIPC(\n presence: Presence,\n processId: string,\n channel: string,\n replyCallback: (method: string, args: any[]) => any,\n) {\n await presence.subscribe(channel, (message) => {\n const [method, requestId, args] = message;\n\n const reply = (code, data) => {\n presence.publish(`ipc:${requestId}`, [code, data]);\n };\n\n // reply with method result\n let response: any;\n try {\n response = replyCallback(method, args);\n\n } catch (e) {\n debugAndPrintError(e);\n const error = (typeof(e.code) !== \"undefined\")\n ? { code: e.code, message: e.message }\n : e.message;\n return reply(IpcProtocol.ERROR, JSON.stringify(error));\n }\n\n if (!(response instanceof Promise)) {\n return reply(IpcProtocol.SUCCESS, response);\n }\n\n response.\n then((result) => reply(IpcProtocol.SUCCESS, result)).\n catch((e) => {\n // user might have called `reject()` without arguments.\n const err = e && e.message || e;\n reply(IpcProtocol.ERROR, err);\n });\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmC;AAEnC,sBAA4B;AAC5B,mBAAsD;AAEtD,eAAsB,eACpB,UACA,kBACA,QACA,MACA,mBAA2B,wCACf;AACZ,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI;AAEJ,UAAM,gBAAY,yBAAW;AAC7B,UAAM,UAAU,OAAO,SAAS;AAEhC,UAAM,cAAc,MAAM;AACxB,eAAS,YAAY,OAAO;AAC5B,mBAAa,kBAAkB;AAAA,IACjC;AAEA,aAAS,UAAU,SAAS,CAAC,YAAY;AACvC,YAAM,CAAC,MAAM,IAAI,IAAI;AACrB,UAAI,SAAS,4BAAY,SAAS;AAChC,gBAAQ,IAAI;AAAA,MAEd,WAAW,SAAS,4BAAY,OAAO;AACrC,YAAI,QAAa;AAGjB,YAAI;AAAE,kBAAQ,KAAK,MAAM,IAAI;AAAA,QAAE,SAAS,GAAG;AAAA,QAAC;AAG5C,YAAI,OAAO,UAAW,UAAU;AAC9B,kBAAQ,IAAI,MAAM,KAAK;AAAA,QACzB;AAEA,eAAO,KAAK;AAAA,MACd;AACA,kBAAY;AAAA,IACd,CAAC;AAED,aAAS,QAAQ,kBAAkB,CAAC,QAAQ,WAAW,IAAI,CAAC;AAE5D,yBAAqB,WAAW,MAAM;AACpC,kBAAY;AACZ,aAAO,IAAI,MAAM,aAAa,CAAC;AAAA,IACjC,GAAG,gBAAgB;AAAA,EACrB,CAAC;AACH;AAEA,eAAsB,aACpB,UACA,WACA,SACA,eACA;AACA,QAAM,SAAS,UAAU,SAAS,CAAC,YAAY;AAC7C,UAAM,CAAC,QAAQ,WAAW,IAAI,IAAI;AAElC,UAAM,QAAQ,CAAC,MAAM,SAAS;AAC5B,eAAS,QAAQ,OAAO,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC;AAAA,IACnD;AAGA,QAAI;AACJ,QAAI;AACF,iBAAW,cAAc,QAAQ,IAAI;AAAA,IAEvC,SAAS,GAAG;AACV,2CAAmB,CAAC;AACpB,YAAM,QAAS,OAAO,EAAE,SAAU,cAC9B,EAAE,MAAM,EAAE,MAAM,SAAS,EAAE,QAAQ,IACnC,EAAE;AACN,aAAO,MAAM,4BAAY,OAAO,KAAK,UAAU,KAAK,CAAC;AAAA,IACvD;AAEA,QAAI,EAAE,oBAAoB,UAAU;AAClC,aAAO,MAAM,4BAAY,SAAS,QAAQ;AAAA,IAC5C;AAEA,aACE,KAAK,CAAC,WAAW,MAAM,4BAAY,SAAS,MAAM,CAAC,EACnD,MAAM,CAAC,MAAM;AAEX,YAAM,MAAM,KAAK,EAAE,WAAW;AAC9B,YAAM,4BAAY,OAAO,GAAG;AAAA,IAC9B,CAAC;AAAA,EACL,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/IPC.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
// packages/core/src/IPC.ts
|
|
2
|
+
import { debugAndPrintError } from "./Debug.mjs";
|
|
3
|
+
import { IpcProtocol } from "./Protocol.mjs";
|
|
4
|
+
import { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from "./utils/Utils.mjs";
|
|
4
5
|
async function requestFromIPC(presence, publishToChannel, method, args, rejectionTimeout = REMOTE_ROOM_SHORT_TIMEOUT) {
|
|
5
6
|
return new Promise((resolve, reject) => {
|
|
6
7
|
let unsubscribeTimeout;
|
package/build/IPC.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/IPC.ts"],
|
|
4
|
-
"sourcesContent": ["import { debugAndPrintError } from './Debug';\nimport { Presence } from './presence/Presence';\nimport { IpcProtocol } from './Protocol';\nimport { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from './utils/Utils';\n\nexport async function requestFromIPC<T>(\n presence: Presence,\n publishToChannel: string,\n method: string,\n args: any[],\n rejectionTimeout: number = REMOTE_ROOM_SHORT_TIMEOUT,\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n let unsubscribeTimeout: NodeJS.Timeout;\n\n const requestId = generateId();\n const channel = `ipc:${requestId}`;\n\n const unsubscribe = () => {\n presence.unsubscribe(channel);\n clearTimeout(unsubscribeTimeout);\n };\n\n presence.subscribe(channel, (message) => {\n const [code, data] = message;\n if (code === IpcProtocol.SUCCESS) {\n resolve(data);\n\n } else if (code === IpcProtocol.ERROR) {\n let error: any = data;\n\n // parse error message + code\n try { error = JSON.parse(data) } catch (e) {}\n\n // turn string message into Error instance\n if (typeof(error) === \"string\") {\n error = new Error(error);\n }\n\n reject(error);\n }\n unsubscribe();\n });\n\n presence.publish(publishToChannel, [method, requestId, args]);\n\n unsubscribeTimeout = setTimeout(() => {\n unsubscribe();\n reject(new Error(\"ipc_timeout\"));\n }, rejectionTimeout);\n });\n}\n\nexport async function subscribeIPC(\n presence: Presence,\n processId: string,\n channel: string,\n replyCallback: (method: string, args: any[]) => any,\n) {\n await presence.subscribe(channel, (message) => {\n const [method, requestId, args] = message;\n\n const reply = (code, data) => {\n presence.publish(`ipc:${requestId}`, [code, data]);\n };\n\n // reply with method result\n let response: any;\n try {\n response = replyCallback(method, args);\n\n } catch (e) {\n debugAndPrintError(e);\n const error = (typeof(e.code) !== \"undefined\")\n ? { code: e.code, message: e.message }\n : e.message;\n return reply(IpcProtocol.ERROR, JSON.stringify(error));\n }\n\n if (!(response instanceof Promise)) {\n return reply(IpcProtocol.SUCCESS, response);\n }\n\n response.\n then((result) => reply(IpcProtocol.SUCCESS, result)).\n catch((e) => {\n // user might have called `reject()` without arguments.\n const err = e && e.message || e;\n reply(IpcProtocol.ERROR, err);\n });\n });\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAC5B,SAAS,YAAY,iCAAiC;AAEtD,eAAsB,eACpB,UACA,kBACA,QACA,MACA,mBAA2B,2BACf;AACZ,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI;AAEJ,UAAM,YAAY,WAAW;AAC7B,UAAM,UAAU,OAAO;
|
|
4
|
+
"sourcesContent": ["import { debugAndPrintError } from './Debug.js';\nimport { Presence } from './presence/Presence.js';\nimport { IpcProtocol } from './Protocol.js';\nimport { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from './utils/Utils.js';\n\nexport async function requestFromIPC<T>(\n presence: Presence,\n publishToChannel: string,\n method: string,\n args: any[],\n rejectionTimeout: number = REMOTE_ROOM_SHORT_TIMEOUT,\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n let unsubscribeTimeout: NodeJS.Timeout;\n\n const requestId = generateId();\n const channel = `ipc:${requestId}`;\n\n const unsubscribe = () => {\n presence.unsubscribe(channel);\n clearTimeout(unsubscribeTimeout);\n };\n\n presence.subscribe(channel, (message) => {\n const [code, data] = message;\n if (code === IpcProtocol.SUCCESS) {\n resolve(data);\n\n } else if (code === IpcProtocol.ERROR) {\n let error: any = data;\n\n // parse error message + code\n try { error = JSON.parse(data) } catch (e) {}\n\n // turn string message into Error instance\n if (typeof(error) === \"string\") {\n error = new Error(error);\n }\n\n reject(error);\n }\n unsubscribe();\n });\n\n presence.publish(publishToChannel, [method, requestId, args]);\n\n unsubscribeTimeout = setTimeout(() => {\n unsubscribe();\n reject(new Error(\"ipc_timeout\"));\n }, rejectionTimeout);\n });\n}\n\nexport async function subscribeIPC(\n presence: Presence,\n processId: string,\n channel: string,\n replyCallback: (method: string, args: any[]) => any,\n) {\n await presence.subscribe(channel, (message) => {\n const [method, requestId, args] = message;\n\n const reply = (code, data) => {\n presence.publish(`ipc:${requestId}`, [code, data]);\n };\n\n // reply with method result\n let response: any;\n try {\n response = replyCallback(method, args);\n\n } catch (e) {\n debugAndPrintError(e);\n const error = (typeof(e.code) !== \"undefined\")\n ? { code: e.code, message: e.message }\n : e.message;\n return reply(IpcProtocol.ERROR, JSON.stringify(error));\n }\n\n if (!(response instanceof Promise)) {\n return reply(IpcProtocol.SUCCESS, response);\n }\n\n response.\n then((result) => reply(IpcProtocol.SUCCESS, result)).\n catch((e) => {\n // user might have called `reject()` without arguments.\n const err = e && e.message || e;\n reply(IpcProtocol.ERROR, err);\n });\n });\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAC5B,SAAS,YAAY,iCAAiC;AAEtD,eAAsB,eACpB,UACA,kBACA,QACA,MACA,mBAA2B,2BACf;AACZ,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI;AAEJ,UAAM,YAAY,WAAW;AAC7B,UAAM,UAAU,OAAO,SAAS;AAEhC,UAAM,cAAc,MAAM;AACxB,eAAS,YAAY,OAAO;AAC5B,mBAAa,kBAAkB;AAAA,IACjC;AAEA,aAAS,UAAU,SAAS,CAAC,YAAY;AACvC,YAAM,CAAC,MAAM,IAAI,IAAI;AACrB,UAAI,SAAS,YAAY,SAAS;AAChC,gBAAQ,IAAI;AAAA,MAEd,WAAW,SAAS,YAAY,OAAO;AACrC,YAAI,QAAa;AAGjB,YAAI;AAAE,kBAAQ,KAAK,MAAM,IAAI;AAAA,QAAE,SAAS,GAAG;AAAA,QAAC;AAG5C,YAAI,OAAO,UAAW,UAAU;AAC9B,kBAAQ,IAAI,MAAM,KAAK;AAAA,QACzB;AAEA,eAAO,KAAK;AAAA,MACd;AACA,kBAAY;AAAA,IACd,CAAC;AAED,aAAS,QAAQ,kBAAkB,CAAC,QAAQ,WAAW,IAAI,CAAC;AAE5D,yBAAqB,WAAW,MAAM;AACpC,kBAAY;AACZ,aAAO,IAAI,MAAM,aAAa,CAAC;AAAA,IACjC,GAAG,gBAAgB;AAAA,EACrB,CAAC;AACH;AAEA,eAAsB,aACpB,UACA,WACA,SACA,eACA;AACA,QAAM,SAAS,UAAU,SAAS,CAAC,YAAY;AAC7C,UAAM,CAAC,QAAQ,WAAW,IAAI,IAAI;AAElC,UAAM,QAAQ,CAAC,MAAM,SAAS;AAC5B,eAAS,QAAQ,OAAO,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC;AAAA,IACnD;AAGA,QAAI;AACJ,QAAI;AACF,iBAAW,cAAc,QAAQ,IAAI;AAAA,IAEvC,SAAS,GAAG;AACV,yBAAmB,CAAC;AACpB,YAAM,QAAS,OAAO,EAAE,SAAU,cAC9B,EAAE,MAAM,EAAE,MAAM,SAAS,EAAE,QAAQ,IACnC,EAAE;AACN,aAAO,MAAM,YAAY,OAAO,KAAK,UAAU,KAAK,CAAC;AAAA,IACvD;AAEA,QAAI,EAAE,oBAAoB,UAAU;AAClC,aAAO,MAAM,YAAY,SAAS,QAAQ;AAAA,IAC5C;AAEA,aACE,KAAK,CAAC,WAAW,MAAM,YAAY,SAAS,MAAM,CAAC,EACnD,MAAM,CAAC,MAAM;AAEX,YAAM,MAAM,KAAK,EAAE,WAAW;AAC9B,YAAM,YAAY,OAAO,GAAG;AAAA,IAC9B,CAAC;AAAA,EACL,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/Logger.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/core/src/Logger.ts
|
|
2
|
+
var Logger = class {
|
|
2
3
|
debug(...args) {
|
|
3
4
|
logger.debug(...args);
|
|
4
5
|
}
|
|
@@ -14,8 +15,8 @@ class Logger {
|
|
|
14
15
|
warn(...args) {
|
|
15
16
|
logger.warn(...args);
|
|
16
17
|
}
|
|
17
|
-
}
|
|
18
|
-
|
|
18
|
+
};
|
|
19
|
+
var logger = console;
|
|
19
20
|
function setLogger(instance) {
|
|
20
21
|
logger = instance;
|
|
21
22
|
}
|
package/build/Logger.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/Logger.ts"],
|
|
4
4
|
"sourcesContent": ["//\n// Abstract logging adaptor\n//\nexport class Logger {\n debug(...args) {\n logger.debug(...args);\n }\n\n error(...args) {\n logger.error(...args);\n }\n\n info(...args) {\n logger.info(...args);\n }\n\n trace(...args) {\n logger.trace(...args);\n }\n\n warn(...args) {\n logger.warn(...args);\n }\n}\n\nexport let logger: Logger = console;\n\nexport function setLogger(instance: Logger) {\n logger = instance;\n}\n"],
|
|
5
|
-
"mappings": "AAGO,
|
|
5
|
+
"mappings": ";AAGO,IAAM,SAAN,MAAa;AAAA,EAClB,SAAS,MAAM;AACb,WAAO,MAAM,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,SAAS,MAAM;AACb,WAAO,MAAM,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,QAAQ,MAAM;AACZ,WAAO,KAAK,GAAG,IAAI;AAAA,EACrB;AAAA,EAEA,SAAS,MAAM;AACb,WAAO,MAAM,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,QAAQ,MAAM;AACZ,WAAO,KAAK,GAAG,IAAI;AAAA,EACrB;AACF;AAEO,IAAI,SAAiB;AAErB,SAAS,UAAU,UAAkB;AAC1C,WAAS;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/MatchMaker.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Deferred } from './utils/Utils';
|
|
2
|
-
import { RegisteredHandler } from './matchmaker/RegisteredHandler';
|
|
3
|
-
import { Room } from './Room';
|
|
4
|
-
import { Presence } from './presence/Presence';
|
|
5
|
-
import {
|
|
6
|
-
import controller from './matchmaker/controller';
|
|
7
|
-
import * as stats from
|
|
8
|
-
import { Type } from './utils/types';
|
|
1
|
+
import { Deferred } from './utils/Utils.js';
|
|
2
|
+
import { RegisteredHandler } from './matchmaker/RegisteredHandler.js';
|
|
3
|
+
import { Room } from './Room.js';
|
|
4
|
+
import { Presence } from './presence/Presence.js';
|
|
5
|
+
import { IRoomCache, MatchMakerDriver, SortOptions } from './matchmaker/driver/local/LocalDriver.js';
|
|
6
|
+
import controller from './matchmaker/controller.js';
|
|
7
|
+
import * as stats from './Stats.js';
|
|
8
|
+
import { Type } from './utils/types.js';
|
|
9
9
|
export { controller, stats, type MatchMakerDriver };
|
|
10
10
|
export type ClientOptions = any;
|
|
11
11
|
export type AuthOptions = {
|
|
@@ -15,7 +15,7 @@ export type AuthOptions = {
|
|
|
15
15
|
export type SelectProcessIdCallback = (roomName: string, clientOptions: ClientOptions) => Promise<string>;
|
|
16
16
|
export interface SeatReservation {
|
|
17
17
|
sessionId: string;
|
|
18
|
-
room:
|
|
18
|
+
room: IRoomCache;
|
|
19
19
|
devMode?: boolean;
|
|
20
20
|
}
|
|
21
21
|
export declare let publicAddress: string;
|
|
@@ -23,7 +23,7 @@ export declare let processId: string;
|
|
|
23
23
|
export declare let presence: Presence;
|
|
24
24
|
export declare let driver: MatchMakerDriver;
|
|
25
25
|
export declare let selectProcessIdToCreateRoom: SelectProcessIdCallback;
|
|
26
|
-
export declare
|
|
26
|
+
export declare function setHealthChecksEnabled(value: boolean): void;
|
|
27
27
|
export declare let onReady: Deferred;
|
|
28
28
|
export declare enum MatchMakerState {
|
|
29
29
|
INITIALIZING = 0,
|
|
@@ -60,7 +60,7 @@ export declare function join(roomName: string, clientOptions?: ClientOptions, au
|
|
|
60
60
|
* Join a room by id and return seat reservation
|
|
61
61
|
*/
|
|
62
62
|
export declare function reconnect(roomId: string, clientOptions?: ClientOptions): Promise<{
|
|
63
|
-
room:
|
|
63
|
+
room: import("./matchmaker/driver/api.js").RoomCache<any>;
|
|
64
64
|
sessionId: any;
|
|
65
65
|
}>;
|
|
66
66
|
/**
|
|
@@ -70,22 +70,23 @@ export declare function reconnect(roomId: string, clientOptions?: ClientOptions)
|
|
|
70
70
|
* @param clientOptions - Options for the client seat reservation (for `onJoin`/`onAuth`)
|
|
71
71
|
* @param authOptions - Optional authentication token
|
|
72
72
|
*
|
|
73
|
-
* @returns Promise<SeatReservation> - A promise which contains `sessionId` and `
|
|
73
|
+
* @returns Promise<SeatReservation> - A promise which contains `sessionId` and `IRoomCache`.
|
|
74
74
|
*/
|
|
75
75
|
export declare function joinById(roomId: string, clientOptions?: ClientOptions, authOptions?: AuthOptions): Promise<SeatReservation>;
|
|
76
76
|
/**
|
|
77
77
|
* Perform a query for all cached rooms
|
|
78
78
|
*/
|
|
79
|
-
export declare function query(conditions?: Partial<
|
|
79
|
+
export declare function query(conditions?: Partial<IRoomCache>, sortOptions?: SortOptions): Promise<IRoomCache[]>;
|
|
80
80
|
/**
|
|
81
81
|
* Find for a public and unlocked room available.
|
|
82
82
|
*
|
|
83
83
|
* @param roomName - The Id of the specific room.
|
|
84
|
-
* @param
|
|
84
|
+
* @param filterOptions - Filter options.
|
|
85
|
+
* @param sortOptions - Sorting options.
|
|
85
86
|
*
|
|
86
|
-
* @returns Promise<
|
|
87
|
+
* @returns Promise<IRoomCache> - A promise contaning an object which includes room metadata and configurations.
|
|
87
88
|
*/
|
|
88
|
-
export declare function findOneRoomAvailable(roomName: string,
|
|
89
|
+
export declare function findOneRoomAvailable(roomName: string, filterOptions: ClientOptions, additionalSortOptions?: SortOptions): Promise<import("./matchmaker/driver/api.js").RoomCache<any>>;
|
|
89
90
|
/**
|
|
90
91
|
* Call a method or return a property on a remote room.
|
|
91
92
|
*
|
|
@@ -107,11 +108,19 @@ export declare function getRoomClass(roomName: string): Type<Room>;
|
|
|
107
108
|
* @param roomName - The identifier you defined on `gameServer.define()`
|
|
108
109
|
* @param clientOptions - Options for `onCreate`
|
|
109
110
|
*
|
|
110
|
-
* @returns Promise<
|
|
111
|
+
* @returns Promise<IRoomCache> - A promise contaning an object which includes room metadata and configurations.
|
|
111
112
|
*/
|
|
112
|
-
export declare function createRoom(roomName: string, clientOptions: ClientOptions): Promise<
|
|
113
|
-
export declare function handleCreateRoom(roomName: string, clientOptions: ClientOptions, restoringRoomId?: string): Promise<
|
|
114
|
-
|
|
113
|
+
export declare function createRoom(roomName: string, clientOptions: ClientOptions): Promise<IRoomCache>;
|
|
114
|
+
export declare function handleCreateRoom(roomName: string, clientOptions: ClientOptions, restoringRoomId?: string): Promise<IRoomCache>;
|
|
115
|
+
/**
|
|
116
|
+
* Get room data by roomId.
|
|
117
|
+
* This method does not return the actual room instance, use `getLocalRoomById` for that.
|
|
118
|
+
*/
|
|
119
|
+
export declare function getRoomById(roomId: string): Promise<import("./matchmaker/driver/api.js").RoomCache<any>>;
|
|
120
|
+
/**
|
|
121
|
+
* Get local room instance by roomId. (Can return "undefined" if the room is not available on this process)
|
|
122
|
+
*/
|
|
123
|
+
export declare function getLocalRoomById(roomId: string): Room<any, any, any, any>;
|
|
115
124
|
/**
|
|
116
125
|
* Disconnects every client on every room in the current process.
|
|
117
126
|
*/
|
|
@@ -120,8 +129,7 @@ export declare function gracefullyShutdown(): Promise<any>;
|
|
|
120
129
|
/**
|
|
121
130
|
* Reserve a seat for a client in a room
|
|
122
131
|
*/
|
|
123
|
-
export declare function reserveSeatFor(room:
|
|
124
|
-
export declare function cleanupStaleRooms(roomName: string): Promise<void>;
|
|
132
|
+
export declare function reserveSeatFor(room: IRoomCache, options: ClientOptions, authData?: any): Promise<SeatReservation>;
|
|
125
133
|
/**
|
|
126
134
|
* Perform health check on all processes
|
|
127
135
|
*/
|