@colyseus/core 0.16.23 → 0.17.0
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 +16 -4
- package/build/Debug.js.map +2 -2
- package/build/Debug.mjs +11 -1
- package/build/Debug.mjs.map +2 -2
- package/build/IPC.js +5 -3
- package/build/IPC.js.map +2 -2
- package/build/IPC.mjs +1 -0
- package/build/IPC.mjs.map +2 -2
- package/build/Logger.js +1 -0
- package/build/Logger.js.map +1 -1
- package/build/MatchMaker.js +148 -84
- package/build/MatchMaker.js.map +3 -3
- package/build/MatchMaker.mjs +130 -70
- package/build/MatchMaker.mjs.map +3 -3
- package/build/Protocol.js +54 -41
- package/build/Protocol.js.map +3 -3
- package/build/Protocol.mjs +52 -41
- package/build/Protocol.mjs.map +3 -3
- package/build/Room.js +430 -195
- package/build/Room.js.map +3 -3
- package/build/Room.mjs +417 -175
- package/build/Room.mjs.map +3 -3
- package/build/Server.js +48 -108
- package/build/Server.js.map +3 -3
- package/build/Server.mjs +39 -102
- package/build/Server.mjs.map +3 -3
- package/build/Stats.js +2 -1
- package/build/Stats.js.map +2 -2
- package/build/Stats.mjs.map +1 -1
- package/build/Transport.js +29 -11
- package/build/Transport.js.map +3 -3
- package/build/Transport.mjs +15 -9
- package/build/Transport.mjs.map +3 -3
- package/build/errors/RoomExceptions.js +9 -5
- package/build/errors/RoomExceptions.js.map +2 -2
- package/build/errors/RoomExceptions.mjs +8 -5
- package/build/errors/RoomExceptions.mjs.map +2 -2
- package/build/errors/SeatReservationError.js +1 -0
- package/build/errors/SeatReservationError.js.map +1 -1
- package/build/errors/ServerError.js +2 -1
- package/build/errors/ServerError.js.map +2 -2
- package/build/errors/ServerError.mjs.map +1 -1
- package/build/index.js +60 -26
- package/build/index.js.map +2 -2
- package/build/index.mjs +33 -7
- package/build/index.mjs.map +2 -2
- package/build/matchmaker/Lobby.js +13 -3
- package/build/matchmaker/Lobby.js.map +2 -2
- package/build/matchmaker/Lobby.mjs +11 -2
- package/build/matchmaker/Lobby.mjs.map +2 -2
- package/build/matchmaker/LocalDriver/LocalDriver.js +94 -0
- package/build/matchmaker/LocalDriver/LocalDriver.js.map +7 -0
- package/build/matchmaker/LocalDriver/LocalDriver.mjs +71 -0
- package/build/matchmaker/LocalDriver/LocalDriver.mjs.map +7 -0
- package/build/matchmaker/LocalDriver/Query.js +111 -0
- package/build/matchmaker/LocalDriver/Query.js.map +7 -0
- package/build/matchmaker/LocalDriver/Query.mjs +88 -0
- package/build/matchmaker/LocalDriver/Query.mjs.map +7 -0
- package/build/matchmaker/RegisteredHandler.js +57 -7
- package/build/matchmaker/RegisteredHandler.js.map +2 -2
- package/build/matchmaker/RegisteredHandler.mjs +54 -5
- package/build/matchmaker/RegisteredHandler.mjs.map +2 -2
- package/build/matchmaker/controller.js +8 -8
- package/build/matchmaker/controller.js.map +2 -2
- package/build/matchmaker/controller.mjs +4 -5
- package/build/matchmaker/controller.mjs.map +2 -2
- package/build/matchmaker/driver/api.js +21 -2
- package/build/matchmaker/driver/api.js.map +2 -2
- package/build/matchmaker/driver/api.mjs +18 -1
- package/build/matchmaker/driver/api.mjs.map +2 -2
- package/build/matchmaker/driver/local/LocalDriver.js +36 -7
- package/build/matchmaker/driver/local/LocalDriver.js.map +2 -2
- package/build/matchmaker/driver/local/LocalDriver.mjs +33 -5
- package/build/matchmaker/driver/local/LocalDriver.mjs.map +2 -2
- package/build/matchmaker/driver/local/Query.js +51 -18
- package/build/matchmaker/driver/local/Query.js.map +2 -2
- package/build/matchmaker/driver/local/Query.mjs +50 -18
- package/build/matchmaker/driver/local/Query.mjs.map +2 -2
- package/build/matchmaker/driver.js +44 -0
- package/build/matchmaker/driver.js.map +7 -0
- package/build/matchmaker/driver.mjs +20 -0
- package/build/matchmaker/driver.mjs.map +7 -0
- package/build/matchmaker/routes.js +79 -0
- package/build/matchmaker/routes.js.map +7 -0
- package/build/matchmaker/routes.mjs +45 -0
- package/build/matchmaker/routes.mjs.map +7 -0
- package/build/presence/LocalPresence.js +13 -27
- package/build/presence/LocalPresence.js.map +3 -3
- package/build/presence/LocalPresence.mjs +11 -16
- package/build/presence/LocalPresence.mjs.map +2 -2
- package/build/presence/Presence.js +37 -0
- package/build/presence/Presence.js.map +2 -2
- package/build/presence/Presence.mjs +29 -0
- package/build/presence/Presence.mjs.map +3 -3
- package/build/rooms/LobbyRoom.js +5 -5
- package/build/rooms/LobbyRoom.js.map +2 -2
- package/build/rooms/LobbyRoom.mjs +1 -2
- package/build/rooms/LobbyRoom.mjs.map +2 -2
- package/build/rooms/RankedQueueRoom.js +224 -0
- package/build/rooms/RankedQueueRoom.js.map +7 -0
- package/build/rooms/RankedQueueRoom.mjs +201 -0
- package/build/rooms/RankedQueueRoom.mjs.map +7 -0
- package/build/rooms/RelayRoom.js +6 -6
- package/build/rooms/RelayRoom.js.map +2 -2
- package/build/rooms/RelayRoom.mjs +4 -5
- package/build/rooms/RelayRoom.mjs.map +2 -2
- package/build/rooms/createRoom.js +51 -0
- package/build/rooms/createRoom.js.map +7 -0
- package/build/rooms/createRoom.mjs +28 -0
- package/build/rooms/createRoom.mjs.map +7 -0
- package/build/router/default_routes.js +79 -0
- package/build/router/default_routes.js.map +7 -0
- package/build/router/default_routes.mjs +45 -0
- package/build/router/default_routes.mjs.map +7 -0
- package/build/router/index.js +55 -0
- package/build/router/index.js.map +7 -0
- package/build/router/index.mjs +30 -0
- package/build/router/index.mjs.map +7 -0
- package/build/serializer/NoneSerializer.js +1 -0
- package/build/serializer/NoneSerializer.js.map +2 -2
- package/build/serializer/NoneSerializer.mjs.map +2 -2
- package/build/serializer/SchemaSerializer.js +6 -7
- package/build/serializer/SchemaSerializer.js.map +2 -2
- package/build/serializer/SchemaSerializer.mjs +3 -5
- package/build/serializer/SchemaSerializer.mjs.map +2 -2
- package/build/serializer/SchemaSerializerDebug.js +29 -0
- package/build/serializer/SchemaSerializerDebug.js.map +3 -3
- package/build/serializer/SchemaSerializerDebug.mjs +7 -0
- package/build/serializer/SchemaSerializerDebug.mjs.map +3 -3
- package/build/serializer/Serializer.js +1 -0
- package/build/serializer/Serializer.js.map +2 -2
- package/build/{Debug.d.ts → src/Debug.d.ts} +2 -1
- package/build/{IPC.d.ts → src/IPC.d.ts} +2 -2
- package/build/{MatchMaker.d.ts → src/MatchMaker.d.ts} +58 -33
- package/build/src/Protocol.d.ts +53 -0
- package/build/src/Room.d.ts +497 -0
- package/build/{Server.d.ts → src/Server.d.ts} +23 -25
- package/build/{Transport.d.ts → src/Transport.d.ts} +65 -22
- package/build/{errors → src/errors}/RoomExceptions.d.ts +8 -7
- package/build/src/index.d.ts +27 -0
- package/build/src/matchmaker/Lobby.d.ts +4 -0
- package/build/src/matchmaker/LocalDriver/LocalDriver.d.ts +17 -0
- package/build/src/matchmaker/LocalDriver/Query.d.ts +12 -0
- package/build/src/matchmaker/RegisteredHandler.d.ts +81 -0
- package/build/{matchmaker → src/matchmaker}/controller.d.ts +5 -6
- package/build/src/matchmaker/driver/api.d.ts +145 -0
- package/build/src/matchmaker/driver/local/LocalDriver.d.ts +17 -0
- package/build/src/matchmaker/driver/local/Query.d.ts +12 -0
- package/build/src/matchmaker/driver.d.ts +145 -0
- package/build/src/matchmaker/routes.d.ts +92 -0
- package/build/{presence → src/presence}/LocalPresence.d.ts +1 -1
- package/build/{presence → src/presence}/Presence.d.ts +2 -0
- package/build/{rooms → src/rooms}/LobbyRoom.d.ts +4 -4
- package/build/src/rooms/RankedQueueRoom.d.ts +125 -0
- package/build/{rooms → src/rooms}/RelayRoom.d.ts +5 -4
- package/build/src/rooms/createRoom.d.ts +65 -0
- package/build/src/router/default_routes.d.ts +103 -0
- package/build/src/router/index.d.ts +68 -0
- package/build/{serializer → src/serializer}/NoneSerializer.d.ts +2 -2
- package/build/{serializer → src/serializer}/SchemaSerializer.d.ts +9 -9
- package/build/{serializer → src/serializer}/Serializer.d.ts +3 -3
- package/build/{utils → src/utils}/DevMode.d.ts +5 -4
- package/build/{utils → src/utils}/StandardSchema.d.ts +1 -1
- package/build/{utils → src/utils}/Utils.d.ts +15 -4
- package/build/utils/DevMode.js +54 -26
- package/build/utils/DevMode.js.map +3 -3
- package/build/utils/DevMode.mjs +44 -19
- package/build/utils/DevMode.mjs.map +2 -2
- package/build/utils/StandardSchema.js.map +1 -1
- package/build/utils/StandardSchema.mjs.map +1 -1
- package/build/utils/Utils.js +8 -15
- package/build/utils/Utils.js.map +3 -3
- package/build/utils/Utils.mjs +6 -4
- package/build/utils/Utils.mjs.map +2 -2
- package/package.json +20 -14
- package/build/Protocol.d.ts +0 -37
- package/build/Room.d.ts +0 -265
- package/build/discovery/index.d.ts +0 -8
- package/build/discovery/index.js +0 -50
- package/build/discovery/index.js.map +0 -7
- package/build/discovery/index.mjs +0 -26
- package/build/discovery/index.mjs.map +0 -7
- package/build/index.d.ts +0 -24
- package/build/matchmaker/Lobby.d.ts +0 -4
- package/build/matchmaker/RegisteredHandler.d.ts +0 -19
- package/build/matchmaker/driver/Query.d.ts +0 -8
- package/build/matchmaker/driver/Query.js +0 -68
- package/build/matchmaker/driver/Query.js.map +0 -7
- package/build/matchmaker/driver/Query.mjs +0 -45
- package/build/matchmaker/driver/Query.mjs.map +0 -7
- package/build/matchmaker/driver/RoomData.d.ts +0 -19
- package/build/matchmaker/driver/RoomData.js +0 -79
- package/build/matchmaker/driver/RoomData.js.map +0 -7
- package/build/matchmaker/driver/RoomData.mjs +0 -56
- package/build/matchmaker/driver/RoomData.mjs.map +0 -7
- package/build/matchmaker/driver/api.d.ts +0 -104
- package/build/matchmaker/driver/index.d.ts +0 -13
- package/build/matchmaker/driver/index.js +0 -64
- package/build/matchmaker/driver/index.js.map +0 -7
- package/build/matchmaker/driver/index.mjs +0 -42
- package/build/matchmaker/driver/index.mjs.map +0 -7
- package/build/matchmaker/driver/interfaces.d.ts +0 -73
- package/build/matchmaker/driver/interfaces.js +0 -15
- package/build/matchmaker/driver/interfaces.js.map +0 -7
- package/build/matchmaker/driver/interfaces.mjs +0 -0
- package/build/matchmaker/driver/interfaces.mjs.map +0 -7
- package/build/matchmaker/driver/local/LocalDriver.d.ts +0 -13
- package/build/matchmaker/driver/local/Query.d.ts +0 -9
- package/build/matchmaker/driver/local/RoomData.d.ts +0 -19
- package/build/matchmaker/driver/local/RoomData.js +0 -79
- package/build/matchmaker/driver/local/RoomData.js.map +0 -7
- package/build/matchmaker/driver/local/RoomData.mjs +0 -57
- package/build/matchmaker/driver/local/RoomData.mjs.map +0 -7
- package/build/utils/types.d.ts +0 -1
- package/build/utils/types.js +0 -15
- package/build/utils/types.js.map +0 -7
- package/build/utils/types.mjs +0 -0
- package/build/utils/types.mjs.map +0 -7
- /package/build/{Logger.d.ts → src/Logger.d.ts} +0 -0
- /package/build/{Stats.d.ts → src/Stats.d.ts} +0 -0
- /package/build/{errors → src/errors}/SeatReservationError.d.ts +0 -0
- /package/build/{errors → src/errors}/ServerError.d.ts +0 -0
- /package/build/{serializer → src/serializer}/SchemaSerializerDebug.d.ts +0 -0
- /package/build/{utils → src/utils}/nanoevents.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
4
|
-
"sourcesContent": [],
|
|
5
|
-
"mappings": "",
|
|
3
|
+
"sources": ["../../src/serializer/SchemaSerializerDebug.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * This serializer is a copy of SchemaSerializer,\n * but it writes debug information to a file.\n *\n * This script must be used\n */\n\nimport fs from 'fs';\nimport { Schema, dumpChanges, Iterator } from '@colyseus/schema';\nimport { SchemaSerializer } from './SchemaSerializer.ts';\nimport { Client, ClientState } from \"../Transport.ts\";\nimport { Protocol} from '../Protocol.ts';\nimport { debugPatch } from '../Debug.ts';\n\n/*\nconst SHARED_VIEW = {};\n\nexport class SchemaSerializerDebug<T> extends SchemaSerializer<T> {\n protected debugStream: fs.WriteStream;\n\n constructor(fileName: string = \"schema-debug.txt\") {\n super();\n\n try { fs.unlinkSync(fileName); } catch (e) {}\n this.debugStream = fs.createWriteStream(fileName, { flags: \"a\" });\n }\n\n public getFullState(client?: Client): Buffer {\n const buf = super.getFullState(client);\n this.debugStream.write(`state:${client.sessionId}:${Array.from(buf).slice(1).join(\",\")}\\n`);\n return buf;\n }\n\n public applyPatches(clients: Client[]) {\n let numClients = clients.length;\n\n const debugChangesDeep = Schema.debugChangesDeep(this.encoder.state);\n\n if (\n numClients == 0 ||\n (\n this.encoder.root.changes.size === 0 &&\n (!this.hasFilters || this.encoder.root.filteredChanges.size === 0)\n )\n ) {\n // skip patching state if:\n // - no clients are connected\n // - no changes were made\n // - no \"filtered changes\" were made when using filters\n return false;\n }\n\n this.needFullEncode = true;\n\n // dump changes for patch debugging\n if (debugPatch.enabled) {\n (debugPatch as any).dumpChanges = dumpChanges(this.encoder.state);\n }\n\n // get patch bytes\n const it: Iterator = { offset: 1 };\n this.encoder.sharedBuffer[0] = Protocol.ROOM_STATE_PATCH;\n\n // encode changes once, for all clients\n const encodedChanges = this.encoder.encode(it);\n\n if (!this.hasFilters) {\n while (numClients--) {\n const client = clients[numClients];\n\n //\n // FIXME: avoid this check for each client\n //\n if (client.state !== ClientState.JOINED) {\n continue;\n }\n\n debugChangesDeep.split(\"\\n\").forEach((line) => {\n this.debugStream.write(`#${client.sessionId}:${line}\\n`);\n });\n this.debugStream.write(`patch:${client.sessionId}:${Array.from(encodedChanges).slice(1).join(\",\")}\\n`);\n\n client.raw(encodedChanges);\n }\n\n } else {\n // cache shared offset\n const sharedOffset = it.offset;\n\n // encode state multiple times, for each client\n while (numClients--) {\n const client = clients[numClients];\n\n //\n // FIXME: avoid this check for each client\n //\n if (client.state !== ClientState.JOINED) {\n continue;\n }\n\n const view = client.view || SHARED_VIEW;\n\n let encodedView = this.views.get(view);\n\n // allow to pass the same encoded view for multiple clients\n if (encodedView === undefined) {\n encodedView = (view === SHARED_VIEW)\n ? encodedChanges\n : this.encoder.encodeView(client.view, sharedOffset, it);\n this.views.set(view, encodedView);\n }\n\n debugChangesDeep.split(\"\\n\").forEach((line) => {\n this.debugStream.write(`#${client.sessionId}:${line}\\n`);\n });\n this.debugStream.write(`patch:${client.sessionId}:${Array.from(encodedView).slice(1).join(\",\")}\\n`);\n\n client.raw(encodedView);\n }\n\n // clear views\n this.views.clear();\n }\n\n // discard changes after sending\n this.encoder.discardChanges();\n\n // debug patches\n if (debugPatch.enabled) {\n debugPatch(\n '%d bytes sent to %d clients, %j',\n encodedChanges.length,\n clients.length,\n (debugPatch as any).dumpChanges,\n );\n }\n\n return true;\n }\n\n public handshake(): Buffer {\n const buf = super.handshake();\n this.debugStream.write(`handshake:${Array.from(buf).join(\",\")}\\n`);\n return buf;\n }\n}\n\n*/"],
|
|
5
|
+
"mappings": ";AAOA,OAAe;AACf,OAA8C;AAC9C,OAAiC;AACjC,OAAqC;AACrC,OAAwB;AACxB,OAA2B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/serializer/Serializer.ts"],
|
|
4
|
-
"sourcesContent": ["import { Client } from '../Transport.
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { Client } from '../Transport.ts';\n\nexport interface Serializer<T> {\n id: string;\n reset(data: any): void;\n getFullState(client?: Client): Uint8Array;\n applyPatches(clients: Client[], state: T): boolean;\n handshake?(): Uint8Array;\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
2
|
export declare const debugConnection: debug.IDebugger;
|
|
3
3
|
export declare const debugDriver: debug.IDebugger;
|
|
4
|
-
export declare const debugError: debug.IDebugger;
|
|
5
4
|
export declare const debugMatchMaking: debug.IDebugger;
|
|
6
5
|
export declare const debugMessage: debug.IDebugger;
|
|
7
6
|
export declare const debugPatch: debug.IDebugger;
|
|
8
7
|
export declare const debugPresence: debug.IDebugger;
|
|
8
|
+
export declare const debugError: debug.IDebugger;
|
|
9
|
+
export declare const debugDevMode: debug.IDebugger;
|
|
9
10
|
export declare const debugAndPrintError: (e: Error | string) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Presence } from './presence/Presence.
|
|
2
|
-
export declare function requestFromIPC<T>(presence: Presence, publishToChannel: string, method: string, args: any[], rejectionTimeout?: number): Promise<T>;
|
|
1
|
+
import { type Presence } from './presence/Presence.ts';
|
|
2
|
+
export declare function requestFromIPC<T>(presence: Presence, publishToChannel: string, method: string | undefined, args: any[], rejectionTimeout?: number): Promise<T>;
|
|
3
3
|
export declare function subscribeIPC(presence: Presence, channel: string, replyCallback: (method: string, args: any[]) => any): Promise<void>;
|
|
4
4
|
/**
|
|
5
5
|
* Wait for a room creation notification via presence publish/subscribe
|
|
@@ -1,32 +1,42 @@
|
|
|
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 { IRoomCache, MatchMakerDriver, SortOptions } from './matchmaker/
|
|
6
|
-
import controller from './matchmaker/controller.
|
|
7
|
-
import * as stats from './Stats.
|
|
8
|
-
import { AuthContext } from './Transport.
|
|
9
|
-
import {
|
|
1
|
+
import { type Type, Deferred, type ExtractMethodOrPropertyType } from './utils/Utils.ts';
|
|
2
|
+
import { RegisteredHandler } from './matchmaker/RegisteredHandler.ts';
|
|
3
|
+
import { type OnCreateOptions, Room } from './Room.ts';
|
|
4
|
+
import { type Presence } from './presence/Presence.ts';
|
|
5
|
+
import { type IRoomCache, type MatchMakerDriver, type SortOptions } from './matchmaker/LocalDriver/LocalDriver.ts';
|
|
6
|
+
import controller from './matchmaker/controller.ts';
|
|
7
|
+
import * as stats from './Stats.ts';
|
|
8
|
+
import type { AuthContext } from './Transport.ts';
|
|
9
|
+
import { type ExtractMetadata } from './matchmaker/driver.ts';
|
|
10
10
|
export { controller, stats, type MatchMakerDriver };
|
|
11
11
|
export type ClientOptions = any;
|
|
12
12
|
export type SelectProcessIdCallback = (roomName: string, clientOptions: ClientOptions) => Promise<string>;
|
|
13
|
-
export interface
|
|
13
|
+
export interface ISeatReservation {
|
|
14
|
+
name: string;
|
|
14
15
|
sessionId: string;
|
|
15
|
-
|
|
16
|
+
roomId: string;
|
|
17
|
+
publicAddress?: string;
|
|
18
|
+
processId?: string;
|
|
19
|
+
reconnectionToken?: string;
|
|
16
20
|
devMode?: boolean;
|
|
17
21
|
}
|
|
18
22
|
export declare let publicAddress: string;
|
|
19
23
|
export declare let processId: string;
|
|
20
24
|
export declare let presence: Presence;
|
|
21
25
|
export declare let driver: MatchMakerDriver;
|
|
26
|
+
/**
|
|
27
|
+
* Function to select the processId to create the room on.
|
|
28
|
+
* By default, returns the process with least amount of rooms created.
|
|
29
|
+
* @returns The processId to create the room on.
|
|
30
|
+
*/
|
|
22
31
|
export declare let selectProcessIdToCreateRoom: SelectProcessIdCallback;
|
|
23
32
|
export declare function setHealthChecksEnabled(value: boolean): void;
|
|
24
33
|
export declare let onReady: Deferred;
|
|
25
|
-
export declare
|
|
26
|
-
INITIALIZING
|
|
27
|
-
READY
|
|
28
|
-
SHUTTING_DOWN
|
|
29
|
-
}
|
|
34
|
+
export declare const MatchMakerState: {
|
|
35
|
+
readonly INITIALIZING: 0;
|
|
36
|
+
readonly READY: 1;
|
|
37
|
+
readonly SHUTTING_DOWN: 2;
|
|
38
|
+
};
|
|
39
|
+
export type MatchMakerState = (typeof MatchMakerState)[keyof typeof MatchMakerState];
|
|
30
40
|
/**
|
|
31
41
|
* Internal MatchMaker state
|
|
32
42
|
*/
|
|
@@ -44,22 +54,19 @@ export declare function accept(): Promise<void>;
|
|
|
44
54
|
/**
|
|
45
55
|
* Join or create into a room and return seat reservation
|
|
46
56
|
*/
|
|
47
|
-
export declare function joinOrCreate(roomName: string, clientOptions?: ClientOptions, authContext?: AuthContext): Promise<
|
|
57
|
+
export declare function joinOrCreate(roomName: string, clientOptions?: ClientOptions, authContext?: AuthContext): Promise<ISeatReservation>;
|
|
48
58
|
/**
|
|
49
59
|
* Create a room and return seat reservation
|
|
50
60
|
*/
|
|
51
|
-
export declare function create(roomName: string, clientOptions?: ClientOptions, authContext?: AuthContext): Promise<
|
|
61
|
+
export declare function create(roomName: string, clientOptions?: ClientOptions, authContext?: AuthContext): Promise<ISeatReservation>;
|
|
52
62
|
/**
|
|
53
63
|
* Join a room and return seat reservation
|
|
54
64
|
*/
|
|
55
|
-
export declare function join(roomName: string, clientOptions?: ClientOptions, authContext?: AuthContext): Promise<
|
|
65
|
+
export declare function join(roomName: string, clientOptions?: ClientOptions, authContext?: AuthContext): Promise<ISeatReservation>;
|
|
56
66
|
/**
|
|
57
67
|
* Join a room by id and return seat reservation
|
|
58
68
|
*/
|
|
59
|
-
export declare function reconnect(roomId: string, clientOptions?: ClientOptions): Promise<
|
|
60
|
-
room: import("./matchmaker/driver/api.js").RoomCache<any>;
|
|
61
|
-
sessionId: any;
|
|
62
|
-
}>;
|
|
69
|
+
export declare function reconnect(roomId: string, clientOptions?: ClientOptions): Promise<ISeatReservation>;
|
|
63
70
|
/**
|
|
64
71
|
* Join a room by id and return client seat reservation. An exception is thrown if a room is not found for roomId.
|
|
65
72
|
*
|
|
@@ -69,11 +76,11 @@ export declare function reconnect(roomId: string, clientOptions?: ClientOptions)
|
|
|
69
76
|
*
|
|
70
77
|
* @returns Promise<SeatReservation> - A promise which contains `sessionId` and `IRoomCache`.
|
|
71
78
|
*/
|
|
72
|
-
export declare function joinById(roomId: string, clientOptions?: ClientOptions, authContext?: AuthContext): Promise<
|
|
79
|
+
export declare function joinById(roomId: string, clientOptions?: ClientOptions, authContext?: AuthContext): Promise<ISeatReservation>;
|
|
73
80
|
/**
|
|
74
81
|
* Perform a query for all cached rooms
|
|
75
82
|
*/
|
|
76
|
-
export declare function query(conditions?: Partial<IRoomCache
|
|
83
|
+
export declare function query<T extends Room = any>(conditions?: Partial<IRoomCache & ExtractMetadata<T>>, sortOptions?: SortOptions): Promise<IRoomCache<ExtractMetadata<T>>[]>;
|
|
77
84
|
/**
|
|
78
85
|
* Find for a public and unlocked room available.
|
|
79
86
|
*
|
|
@@ -83,7 +90,7 @@ export declare function query(conditions?: Partial<IRoomCache>, sortOptions?: So
|
|
|
83
90
|
*
|
|
84
91
|
* @returns Promise<IRoomCache> - A promise contaning an object which includes room metadata and configurations.
|
|
85
92
|
*/
|
|
86
|
-
export declare function findOneRoomAvailable(roomName: string, filterOptions: ClientOptions, additionalSortOptions?: SortOptions): Promise<
|
|
93
|
+
export declare function findOneRoomAvailable(roomName: string, filterOptions: ClientOptions, additionalSortOptions?: SortOptions): Promise<IRoomCache<any>>;
|
|
87
94
|
/**
|
|
88
95
|
* Call a method or return a property on a remote room.
|
|
89
96
|
*
|
|
@@ -93,11 +100,14 @@ export declare function findOneRoomAvailable(roomName: string, filterOptions: Cl
|
|
|
93
100
|
*
|
|
94
101
|
* @returns Promise<any> - Returned value from the called or retrieved method/attribute.
|
|
95
102
|
*/
|
|
96
|
-
export declare function remoteRoomCall<
|
|
97
|
-
export declare function defineRoomType<T extends Type<Room>>(roomName: string, klass: T, defaultOptions?:
|
|
103
|
+
export declare function remoteRoomCall<TRoom = Room>(roomId: string, method: keyof TRoom, args?: any[], rejectionTimeout?: number): Promise<ExtractMethodOrPropertyType<TRoom, typeof method>>;
|
|
104
|
+
export declare function defineRoomType<T extends Type<Room>>(roomName: string, klass: T, defaultOptions?: OnCreateOptions<T>): RegisteredHandler<T>;
|
|
105
|
+
export declare function addRoomType(handler: RegisteredHandler): void;
|
|
98
106
|
export declare function removeRoomType(roomName: string): void;
|
|
99
|
-
export declare function
|
|
100
|
-
|
|
107
|
+
export declare function getAllHandlers(): {
|
|
108
|
+
[id: string]: RegisteredHandler<any>;
|
|
109
|
+
};
|
|
110
|
+
export declare function getHandler(roomName: string): RegisteredHandler<any>;
|
|
101
111
|
export declare function getRoomClass(roomName: string): Type<Room>;
|
|
102
112
|
/**
|
|
103
113
|
* Creates a new room.
|
|
@@ -113,11 +123,11 @@ export declare function handleCreateRoom(roomName: string, clientOptions: Client
|
|
|
113
123
|
* Get room data by roomId.
|
|
114
124
|
* This method does not return the actual room instance, use `getLocalRoomById` for that.
|
|
115
125
|
*/
|
|
116
|
-
export declare function getRoomById(roomId: string): Promise<
|
|
126
|
+
export declare function getRoomById(roomId: string): Promise<IRoomCache<any>>;
|
|
117
127
|
/**
|
|
118
128
|
* Get local room instance by roomId. (Can return "undefined" if the room is not available on this process)
|
|
119
129
|
*/
|
|
120
|
-
export declare function getLocalRoomById(roomId: string): Room<
|
|
130
|
+
export declare function getLocalRoomById(roomId: string): Room<import("./Room.ts").RoomOptions>;
|
|
121
131
|
/**
|
|
122
132
|
* Disconnects every client on every room in the current process.
|
|
123
133
|
*/
|
|
@@ -126,7 +136,22 @@ export declare function gracefullyShutdown(): Promise<any>;
|
|
|
126
136
|
/**
|
|
127
137
|
* Reserve a seat for a client in a room
|
|
128
138
|
*/
|
|
129
|
-
export declare function reserveSeatFor(room: IRoomCache, options: ClientOptions, authData?: any): Promise<
|
|
139
|
+
export declare function reserveSeatFor(room: IRoomCache, options: ClientOptions, authData?: any): Promise<ISeatReservation>;
|
|
140
|
+
/**
|
|
141
|
+
* Reserve multiple seats for clients in a room
|
|
142
|
+
*/
|
|
143
|
+
export declare function reserveMultipleSeatsFor(room: IRoomCache, clientsData: Array<{
|
|
144
|
+
sessionId: string;
|
|
145
|
+
options: ClientOptions;
|
|
146
|
+
auth: any;
|
|
147
|
+
}>): Promise<boolean[]>;
|
|
148
|
+
/**
|
|
149
|
+
* Build a seat reservation object.
|
|
150
|
+
* @param room - The room to build a seat reservation for.
|
|
151
|
+
* @param sessionId - The session ID of the client.
|
|
152
|
+
* @returns A seat reservation object.
|
|
153
|
+
*/
|
|
154
|
+
export declare function buildSeatReservation(room: IRoomCache, sessionId: string): ISeatReservation;
|
|
130
155
|
/**
|
|
131
156
|
* Perform health check on all processes
|
|
132
157
|
*/
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colyseus protocol codes range between 0~100
|
|
3
|
+
*/
|
|
4
|
+
export declare const Protocol: {
|
|
5
|
+
readonly JOIN_ROOM: 10;
|
|
6
|
+
readonly ERROR: 11;
|
|
7
|
+
readonly LEAVE_ROOM: 12;
|
|
8
|
+
readonly ROOM_DATA: 13;
|
|
9
|
+
readonly ROOM_STATE: 14;
|
|
10
|
+
readonly ROOM_STATE_PATCH: 15;
|
|
11
|
+
readonly ROOM_DATA_BYTES: 17;
|
|
12
|
+
readonly PING: 18;
|
|
13
|
+
};
|
|
14
|
+
export type Protocol = typeof Protocol[keyof typeof Protocol];
|
|
15
|
+
/**
|
|
16
|
+
* WebSocket close codes
|
|
17
|
+
* (See https://github.com/Luka967/websocket-close-codes)
|
|
18
|
+
*/
|
|
19
|
+
export declare const CloseCode: {
|
|
20
|
+
readonly NORMAL_CLOSURE: 1000;
|
|
21
|
+
readonly GOING_AWAY: 1001;
|
|
22
|
+
readonly NO_STATUS_RECEIVED: 1005;
|
|
23
|
+
readonly ABNORMAL_CLOSURE: 1006;
|
|
24
|
+
readonly CONSENTED: 4000;
|
|
25
|
+
readonly SERVER_SHUTDOWN: 4001;
|
|
26
|
+
readonly WITH_ERROR: 4002;
|
|
27
|
+
readonly DEVMODE_RESTART: 4010;
|
|
28
|
+
};
|
|
29
|
+
export type CloseCode = typeof CloseCode[keyof typeof CloseCode];
|
|
30
|
+
export declare const ErrorCode: {
|
|
31
|
+
readonly MATCHMAKE_NO_HANDLER: 520;
|
|
32
|
+
readonly MATCHMAKE_INVALID_CRITERIA: 521;
|
|
33
|
+
readonly MATCHMAKE_INVALID_ROOM_ID: 522;
|
|
34
|
+
readonly MATCHMAKE_UNHANDLED: 523;
|
|
35
|
+
readonly MATCHMAKE_EXPIRED: 524;
|
|
36
|
+
readonly AUTH_FAILED: 525;
|
|
37
|
+
readonly APPLICATION_ERROR: 526;
|
|
38
|
+
readonly INVALID_PAYLOAD: 4217;
|
|
39
|
+
};
|
|
40
|
+
export type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode];
|
|
41
|
+
export declare const IpcProtocol: {
|
|
42
|
+
readonly SUCCESS: 0;
|
|
43
|
+
readonly ERROR: 1;
|
|
44
|
+
readonly TIMEOUT: 2;
|
|
45
|
+
};
|
|
46
|
+
export type IpcProtocol = typeof IpcProtocol[keyof typeof IpcProtocol];
|
|
47
|
+
export declare const getMessageBytes: {
|
|
48
|
+
10: (reconnectionToken: string, serializerId: string, handshake?: Uint8Array) => Buffer<ArrayBuffer>;
|
|
49
|
+
11: (code: number, message?: string) => Buffer<ArrayBuffer>;
|
|
50
|
+
14: (bytes: number[]) => number[];
|
|
51
|
+
18: () => Buffer<ArrayBuffer>;
|
|
52
|
+
raw: (code: Protocol, type: string | number, message?: any, rawMessage?: Uint8Array | Buffer) => Buffer<ArrayBuffer>;
|
|
53
|
+
};
|