@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
package/build/Protocol.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export declare enum Protocol {
|
|
2
|
-
JOIN_ROOM = 10,
|
|
3
|
-
ERROR = 11,
|
|
4
|
-
LEAVE_ROOM = 12,
|
|
5
|
-
ROOM_DATA = 13,
|
|
6
|
-
ROOM_STATE = 14,
|
|
7
|
-
ROOM_STATE_PATCH = 15,
|
|
8
|
-
ROOM_DATA_BYTES = 17,
|
|
9
|
-
WS_CLOSE_NORMAL = 1000,
|
|
10
|
-
WS_CLOSE_GOING_AWAY = 1001,
|
|
11
|
-
WS_CLOSE_CONSENTED = 4000,
|
|
12
|
-
WS_CLOSE_WITH_ERROR = 4002,
|
|
13
|
-
WS_CLOSE_DEVMODE_RESTART = 4010,
|
|
14
|
-
WS_SERVER_DISCONNECT = 4201,
|
|
15
|
-
WS_TOO_MANY_CLIENTS = 4202
|
|
16
|
-
}
|
|
17
|
-
export declare enum ErrorCode {
|
|
18
|
-
MATCHMAKE_NO_HANDLER = 4210,
|
|
19
|
-
MATCHMAKE_INVALID_CRITERIA = 4211,
|
|
20
|
-
MATCHMAKE_INVALID_ROOM_ID = 4212,
|
|
21
|
-
MATCHMAKE_UNHANDLED = 4213,// generic exception during onCreate/onJoin
|
|
22
|
-
MATCHMAKE_EXPIRED = 4214,// generic exception during onCreate/onJoin
|
|
23
|
-
AUTH_FAILED = 4215,
|
|
24
|
-
APPLICATION_ERROR = 4216,
|
|
25
|
-
INVALID_PAYLOAD = 4217
|
|
26
|
-
}
|
|
27
|
-
export declare enum IpcProtocol {
|
|
28
|
-
SUCCESS = 0,
|
|
29
|
-
ERROR = 1,
|
|
30
|
-
TIMEOUT = 2
|
|
31
|
-
}
|
|
32
|
-
export declare const getMessageBytes: {
|
|
33
|
-
10: (reconnectionToken: string, serializerId: string, handshake?: Buffer) => Buffer<ArrayBuffer>;
|
|
34
|
-
11: (code: number, message?: string) => Buffer<ArrayBuffer>;
|
|
35
|
-
14: (bytes: number[]) => number[];
|
|
36
|
-
raw: (code: Protocol, type: string | number, message?: any, rawMessage?: Uint8Array | Buffer) => Buffer<ArrayBuffer>;
|
|
37
|
-
};
|
package/build/Room.d.ts
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import Clock from '@colyseus/timer';
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import { Presence } from './presence/Presence.js';
|
|
4
|
-
import { Serializer } from './serializer/Serializer.js';
|
|
5
|
-
import { Deferred } from './utils/Utils.js';
|
|
6
|
-
import { RoomCache } from './matchmaker/driver/api.js';
|
|
7
|
-
import { AuthContext, Client, ClientPrivate, ClientArray, ISendOptions } from './Transport.js';
|
|
8
|
-
import { RoomException } from './errors/RoomExceptions.js';
|
|
9
|
-
export declare const DEFAULT_SEAT_RESERVATION_TIME: number;
|
|
10
|
-
export type SimulationCallback = (deltaTime: number) => void;
|
|
11
|
-
export interface IBroadcastOptions extends ISendOptions {
|
|
12
|
-
except?: Client | Client[];
|
|
13
|
-
}
|
|
14
|
-
export declare enum RoomInternalState {
|
|
15
|
-
CREATING = 0,
|
|
16
|
-
CREATED = 1,
|
|
17
|
-
DISPOSING = 2
|
|
18
|
-
}
|
|
19
|
-
export type ExtractUserData<T> = T extends ClientArray<infer U> ? U : never;
|
|
20
|
-
export type ExtractAuthData<T> = T extends ClientArray<infer _, infer U> ? U : never;
|
|
21
|
-
/**
|
|
22
|
-
* A Room class is meant to implement a game session, and/or serve as the communication channel
|
|
23
|
-
* between a group of clients.
|
|
24
|
-
*
|
|
25
|
-
* - Rooms are created on demand during matchmaking by default
|
|
26
|
-
* - Room classes must be exposed using `.define()`
|
|
27
|
-
*/
|
|
28
|
-
export declare abstract class Room<State extends object = any, Metadata = any, UserData = any, AuthData = any> {
|
|
29
|
-
#private;
|
|
30
|
-
/**
|
|
31
|
-
* This property will change on these situations:
|
|
32
|
-
* - The maximum number of allowed clients has been reached (`maxClients`)
|
|
33
|
-
* - You manually locked, or unlocked the room using lock() or `unlock()`.
|
|
34
|
-
*
|
|
35
|
-
* @readonly
|
|
36
|
-
*/
|
|
37
|
-
get locked(): boolean;
|
|
38
|
-
get metadata(): Metadata;
|
|
39
|
-
listing: RoomCache<Metadata>;
|
|
40
|
-
/**
|
|
41
|
-
* Timing events tied to the room instance.
|
|
42
|
-
* Intervals and timeouts are cleared when the room is disposed.
|
|
43
|
-
*/
|
|
44
|
-
clock: Clock;
|
|
45
|
-
/**
|
|
46
|
-
* Maximum number of clients allowed to connect into the room. When room reaches this limit,
|
|
47
|
-
* it is locked automatically. Unless the room was explicitly locked by you via `lock()` method,
|
|
48
|
-
* the room will be unlocked as soon as a client disconnects from it.
|
|
49
|
-
*/
|
|
50
|
-
maxClients: number;
|
|
51
|
-
/**
|
|
52
|
-
* Automatically dispose the room when last client disconnects.
|
|
53
|
-
*
|
|
54
|
-
* @default true
|
|
55
|
-
*/
|
|
56
|
-
autoDispose: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Frequency to send the room state to connected clients, in milliseconds.
|
|
59
|
-
*
|
|
60
|
-
* @default 50ms (20fps)
|
|
61
|
-
*/
|
|
62
|
-
patchRate: number;
|
|
63
|
-
/**
|
|
64
|
-
* The state instance you provided to `setState()`.
|
|
65
|
-
*/
|
|
66
|
-
state: State;
|
|
67
|
-
/**
|
|
68
|
-
* The presence instance. Check Presence API for more details.
|
|
69
|
-
*
|
|
70
|
-
* @see {@link https://docs.colyseus.io/colyseus/server/presence/|Presence API}
|
|
71
|
-
*/
|
|
72
|
-
presence: Presence;
|
|
73
|
-
/**
|
|
74
|
-
* The array of connected clients.
|
|
75
|
-
*
|
|
76
|
-
* @see {@link https://docs.colyseus.io/colyseus/server/room/#client|Client instance}
|
|
77
|
-
*/
|
|
78
|
-
clients: ClientArray<UserData, AuthData>;
|
|
79
|
-
/** @internal */
|
|
80
|
-
_events: EventEmitter<[never]>;
|
|
81
|
-
protected seatReservationTime: number;
|
|
82
|
-
protected reservedSeats: {
|
|
83
|
-
[sessionId: string]: [any, any, boolean?, boolean?];
|
|
84
|
-
};
|
|
85
|
-
protected reservedSeatTimeouts: {
|
|
86
|
-
[sessionId: string]: NodeJS.Timeout;
|
|
87
|
-
};
|
|
88
|
-
protected _reconnections: {
|
|
89
|
-
[reconnectionToken: string]: [string, Deferred];
|
|
90
|
-
};
|
|
91
|
-
private _reconnectingSessionId;
|
|
92
|
-
private onMessageHandlers;
|
|
93
|
-
private _serializer;
|
|
94
|
-
private _afterNextPatchQueue;
|
|
95
|
-
private _simulationInterval;
|
|
96
|
-
private _internalState;
|
|
97
|
-
private _lockedExplicitly;
|
|
98
|
-
private _autoDisposeTimeout;
|
|
99
|
-
constructor();
|
|
100
|
-
/**
|
|
101
|
-
* This method is called by the MatchMaker before onCreate()
|
|
102
|
-
* @internal
|
|
103
|
-
*/
|
|
104
|
-
protected __init(): void;
|
|
105
|
-
/**
|
|
106
|
-
* The name of the room you provided as first argument for `gameServer.define()`.
|
|
107
|
-
*
|
|
108
|
-
* @returns roomName string
|
|
109
|
-
*/
|
|
110
|
-
get roomName(): string;
|
|
111
|
-
/**
|
|
112
|
-
* Setting the name of the room. Overwriting this property is restricted.
|
|
113
|
-
*
|
|
114
|
-
* @param roomName
|
|
115
|
-
*/
|
|
116
|
-
set roomName(roomName: string);
|
|
117
|
-
/**
|
|
118
|
-
* A unique, auto-generated, 9-character-long id of the room.
|
|
119
|
-
* You may replace `this.roomId` during `onCreate()`.
|
|
120
|
-
*
|
|
121
|
-
* @returns roomId string
|
|
122
|
-
*/
|
|
123
|
-
get roomId(): string;
|
|
124
|
-
/**
|
|
125
|
-
* Setting the roomId, is restricted in room lifetime except upon room creation.
|
|
126
|
-
*
|
|
127
|
-
* @param roomId
|
|
128
|
-
* @returns roomId string
|
|
129
|
-
*/
|
|
130
|
-
set roomId(roomId: string);
|
|
131
|
-
onBeforePatch?(state: State): void | Promise<any>;
|
|
132
|
-
onCreate?(options: any): void | Promise<any>;
|
|
133
|
-
onJoin?(client: Client<UserData, AuthData>, options?: any, auth?: AuthData): void | Promise<any>;
|
|
134
|
-
onLeave?(client: Client<UserData, AuthData>, consented?: boolean): void | Promise<any>;
|
|
135
|
-
onDispose?(): void | Promise<any>;
|
|
136
|
-
/**
|
|
137
|
-
* Define a custom exception handler.
|
|
138
|
-
* If defined, all lifecycle hooks will be wrapped by try/catch, and the exception will be forwarded to this method.
|
|
139
|
-
*
|
|
140
|
-
* These methods will be wrapped by try/catch:
|
|
141
|
-
* - `onMessage`
|
|
142
|
-
* - `onAuth` / `onJoin` / `onLeave` / `onCreate` / `onDispose`
|
|
143
|
-
* - `clock.setTimeout` / `clock.setInterval`
|
|
144
|
-
* - `setSimulationInterval`
|
|
145
|
-
*
|
|
146
|
-
* (Experimental: this feature is subject to change in the future - we're currently getting feedback to improve it)
|
|
147
|
-
*/
|
|
148
|
-
onUncaughtException?(error: RoomException<this>, methodName: 'onCreate' | 'onAuth' | 'onJoin' | 'onLeave' | 'onDispose' | 'onMessage' | 'setSimulationInterval' | 'setInterval' | 'setTimeout'): void;
|
|
149
|
-
onAuth(client: Client<UserData, AuthData>, options: any, context: AuthContext): any | Promise<any>;
|
|
150
|
-
static onAuth(token: string, options: any, context: AuthContext): Promise<unknown>;
|
|
151
|
-
/**
|
|
152
|
-
* This method is called during graceful shutdown of the server process
|
|
153
|
-
* You may override this method to dispose the room in your own way.
|
|
154
|
-
*
|
|
155
|
-
* Once process reaches room count of 0, the room process will be terminated.
|
|
156
|
-
*/
|
|
157
|
-
onBeforeShutdown(): void;
|
|
158
|
-
/**
|
|
159
|
-
* devMode: When `devMode` is enabled, `onCacheRoom` method is called during
|
|
160
|
-
* graceful shutdown.
|
|
161
|
-
*
|
|
162
|
-
* Implement this method to return custom data to be cached. `onRestoreRoom`
|
|
163
|
-
* will be called with the data returned by `onCacheRoom`
|
|
164
|
-
*/
|
|
165
|
-
onCacheRoom?(): any;
|
|
166
|
-
/**
|
|
167
|
-
* devMode: When `devMode` is enabled, `onRestoreRoom` method is called during
|
|
168
|
-
* process startup, with the data returned by the `onCacheRoom` method.
|
|
169
|
-
*/
|
|
170
|
-
onRestoreRoom?(cached?: any): void;
|
|
171
|
-
/**
|
|
172
|
-
* Returns whether the sum of connected clients and reserved seats exceeds maximum number of clients.
|
|
173
|
-
*
|
|
174
|
-
* @returns boolean
|
|
175
|
-
*/
|
|
176
|
-
hasReachedMaxClients(): boolean;
|
|
177
|
-
/**
|
|
178
|
-
* Set the number of seconds a room can wait for a client to effectively join the room.
|
|
179
|
-
* You should consider how long your `onAuth()` will have to wait for setting a different seat reservation time.
|
|
180
|
-
* The default value is 15 seconds. You may set the `COLYSEUS_SEAT_RESERVATION_TIME`
|
|
181
|
-
* environment variable if you'd like to change the seat reservation time globally.
|
|
182
|
-
*
|
|
183
|
-
* @default 15 seconds
|
|
184
|
-
*
|
|
185
|
-
* @param seconds - number of seconds.
|
|
186
|
-
* @returns The modified Room object.
|
|
187
|
-
*/
|
|
188
|
-
setSeatReservationTime(seconds: number): this;
|
|
189
|
-
hasReservedSeat(sessionId: string, reconnectionToken?: string): boolean;
|
|
190
|
-
checkReconnectionToken(reconnectionToken: string): string;
|
|
191
|
-
/**
|
|
192
|
-
* (Optional) Set a simulation interval that can change the state of the game.
|
|
193
|
-
* The simulation interval is your game loop.
|
|
194
|
-
*
|
|
195
|
-
* @default 16.6ms (60fps)
|
|
196
|
-
*
|
|
197
|
-
* @param onTickCallback - You can implement your physics or world updates here!
|
|
198
|
-
* This is a good place to update the room state.
|
|
199
|
-
* @param delay - Interval delay on executing `onTickCallback` in milliseconds.
|
|
200
|
-
*/
|
|
201
|
-
setSimulationInterval(onTickCallback?: SimulationCallback, delay?: number): void;
|
|
202
|
-
/**
|
|
203
|
-
* @deprecated Use `.patchRate=` instead.
|
|
204
|
-
*/
|
|
205
|
-
setPatchRate(milliseconds: number | null): void;
|
|
206
|
-
/**
|
|
207
|
-
* @deprecated Use `.state =` instead.
|
|
208
|
-
*/
|
|
209
|
-
setState(newState: State): void;
|
|
210
|
-
setSerializer(serializer: Serializer<State>): void;
|
|
211
|
-
setMetadata(meta: Partial<Metadata>): Promise<void>;
|
|
212
|
-
setPrivate(bool?: boolean): Promise<void>;
|
|
213
|
-
/**
|
|
214
|
-
* Locking the room will remove it from the pool of available rooms for new clients to connect to.
|
|
215
|
-
*/
|
|
216
|
-
lock(): Promise<void>;
|
|
217
|
-
/**
|
|
218
|
-
* Unlocking the room returns it to the pool of available rooms for new clients to connect to.
|
|
219
|
-
*/
|
|
220
|
-
unlock(): Promise<void>;
|
|
221
|
-
send(client: Client, type: string | number, message: any, options?: ISendOptions): void;
|
|
222
|
-
broadcast(type: string | number, message?: any, options?: IBroadcastOptions): void;
|
|
223
|
-
/**
|
|
224
|
-
* Broadcast bytes (UInt8Arrays) to a particular room
|
|
225
|
-
*/
|
|
226
|
-
broadcastBytes(type: string | number, message: Uint8Array, options: IBroadcastOptions): void;
|
|
227
|
-
/**
|
|
228
|
-
* Checks whether mutations have occurred in the state, and broadcast them to all connected clients.
|
|
229
|
-
*/
|
|
230
|
-
broadcastPatch(): boolean;
|
|
231
|
-
onMessage<T = any>(messageType: '*', callback: (client: Client<UserData, AuthData>, type: string | number, message: T) => void): any;
|
|
232
|
-
onMessage<T = any>(messageType: string | number, callback: (client: Client<UserData, AuthData>, message: T) => void, validate?: (message: unknown) => T): any;
|
|
233
|
-
/**
|
|
234
|
-
* Disconnect all connected clients, and then dispose the room.
|
|
235
|
-
*
|
|
236
|
-
* @param closeCode WebSocket close code (default = 4000, which is a "consented leave")
|
|
237
|
-
* @returns Promise<void>
|
|
238
|
-
*/
|
|
239
|
-
disconnect(closeCode?: number): Promise<any>;
|
|
240
|
-
['_onJoin'](client: Client & ClientPrivate, authContext: AuthContext): Promise<void>;
|
|
241
|
-
/**
|
|
242
|
-
* Allow the specified client to reconnect into the room. Must be used inside `onLeave()` method.
|
|
243
|
-
* If seconds is provided, the reconnection is going to be cancelled after the provided amount of seconds.
|
|
244
|
-
*
|
|
245
|
-
* @param previousClient - The client which is to be waiting until re-connection happens.
|
|
246
|
-
* @param seconds - Timeout period on re-connection in seconds.
|
|
247
|
-
*
|
|
248
|
-
* @returns Deferred<Client> - The differed is a promise like type.
|
|
249
|
-
* This type can forcibly reject the promise by calling `.reject()`.
|
|
250
|
-
*/
|
|
251
|
-
allowReconnection(previousClient: Client, seconds: number | "manual"): Deferred<Client>;
|
|
252
|
-
protected resetAutoDisposeTimeout(timeoutInSeconds?: number): void;
|
|
253
|
-
private broadcastMessageType;
|
|
254
|
-
protected sendFullState(client: Client): void;
|
|
255
|
-
protected _dequeueAfterPatchMessages(): void;
|
|
256
|
-
protected _reserveSeat(sessionId: string, joinOptions?: any, authData?: any, seconds?: number, allowReconnection?: boolean, devModeReconnection?: boolean): Promise<boolean>;
|
|
257
|
-
protected _disposeIfEmpty(): boolean;
|
|
258
|
-
protected _dispose(): Promise<any>;
|
|
259
|
-
protected _onMessage(client: Client & ClientPrivate, buffer: Buffer): void;
|
|
260
|
-
protected _forciblyCloseClient(client: Client & ClientPrivate, closeCode: number): void;
|
|
261
|
-
protected _onLeave(client: Client, code?: number): Promise<any>;
|
|
262
|
-
protected _onAfterLeave(client: Client): Promise<void>;
|
|
263
|
-
protected _incrementClientCount(): Promise<void>;
|
|
264
|
-
protected _decrementClientCount(): Promise<boolean>;
|
|
265
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Presence } from '../presence/Presence.js';
|
|
2
|
-
export interface Node {
|
|
3
|
-
port: number;
|
|
4
|
-
processId: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function getHostname(): Promise<string>;
|
|
7
|
-
export declare function registerNode(presence: Presence, node: Node): Promise<void>;
|
|
8
|
-
export declare function unregisterNode(presence: Presence, node: Node): Promise<void>;
|
package/build/discovery/index.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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 discovery_exports = {};
|
|
19
|
-
__export(discovery_exports, {
|
|
20
|
-
getHostname: () => getHostname,
|
|
21
|
-
registerNode: () => registerNode,
|
|
22
|
-
unregisterNode: () => unregisterNode
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(discovery_exports);
|
|
25
|
-
const NODES_SET = "colyseus:nodes";
|
|
26
|
-
const DISCOVERY_CHANNEL = "colyseus:nodes:discovery";
|
|
27
|
-
async function getHostname() {
|
|
28
|
-
return process.env.SELF_HOSTNAME;
|
|
29
|
-
}
|
|
30
|
-
async function getNodeAddress(node) {
|
|
31
|
-
const host = await getHostname();
|
|
32
|
-
const port = process.env.SELF_PORT ?? node.port;
|
|
33
|
-
return port ? `${node.processId}/${host}:${port}` : `${node.processId}/${host}`;
|
|
34
|
-
}
|
|
35
|
-
async function registerNode(presence, node) {
|
|
36
|
-
const nodeAddress = await getNodeAddress(node);
|
|
37
|
-
await presence.sadd(NODES_SET, nodeAddress);
|
|
38
|
-
await presence.publish(DISCOVERY_CHANNEL, `add,${nodeAddress}`);
|
|
39
|
-
}
|
|
40
|
-
async function unregisterNode(presence, node) {
|
|
41
|
-
const nodeAddress = await getNodeAddress(node);
|
|
42
|
-
await presence.srem(NODES_SET, nodeAddress);
|
|
43
|
-
await presence.publish(DISCOVERY_CHANNEL, `remove,${nodeAddress}`);
|
|
44
|
-
}
|
|
45
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
-
0 && (module.exports = {
|
|
47
|
-
getHostname,
|
|
48
|
-
registerNode,
|
|
49
|
-
unregisterNode
|
|
50
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/discovery/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { Presence } from '../presence/Presence.js';\n\nconst NODES_SET = 'colyseus:nodes';\nconst DISCOVERY_CHANNEL = 'colyseus:nodes:discovery';\n\nexport interface Node {\n port: number;\n processId: string;\n}\n\nexport async function getHostname() {\n return process.env.SELF_HOSTNAME;\n}\n\nasync function getNodeAddress(node: Node) {\n const host = await getHostname();\n const port = process.env.SELF_PORT ?? node.port;\n return (port)\n ? `${node.processId}/${host}:${port}`\n : `${node.processId}/${host}`;\n}\n\nexport async function registerNode(presence: Presence, node: Node) {\n const nodeAddress = await getNodeAddress(node);\n await presence.sadd(NODES_SET, nodeAddress);\n await presence.publish(DISCOVERY_CHANNEL, `add,${nodeAddress}`);\n}\n\nexport async function unregisterNode(presence: Presence, node: Node) {\n const nodeAddress = await getNodeAddress(node);\n await presence.srem(NODES_SET, nodeAddress);\n await presence.publish(DISCOVERY_CHANNEL, `remove,${nodeAddress}`);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,MAAM,YAAY;AAClB,MAAM,oBAAoB;AAO1B,eAAsB,cAAc;AAClC,SAAO,QAAQ,IAAI;AACrB;AAEA,eAAe,eAAe,MAAY;AACxC,QAAM,OAAO,MAAM,YAAY;AAC/B,QAAM,OAAO,QAAQ,IAAI,aAAa,KAAK;AAC3C,SAAQ,OACJ,GAAG,KAAK,SAAS,IAAI,IAAI,IAAI,IAAI,KACjC,GAAG,KAAK,SAAS,IAAI,IAAI;AAC/B;AAEA,eAAsB,aAAa,UAAoB,MAAY;AACjE,QAAM,cAAc,MAAM,eAAe,IAAI;AAC7C,QAAM,SAAS,KAAK,WAAW,WAAW;AAC1C,QAAM,SAAS,QAAQ,mBAAmB,OAAO,WAAW,EAAE;AAChE;AAEA,eAAsB,eAAe,UAAoB,MAAY;AACnE,QAAM,cAAc,MAAM,eAAe,IAAI;AAC7C,QAAM,SAAS,KAAK,WAAW,WAAW;AAC1C,QAAM,SAAS,QAAQ,mBAAmB,UAAU,WAAW,EAAE;AACnE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// packages/core/src/discovery/index.ts
|
|
2
|
-
var NODES_SET = "colyseus:nodes";
|
|
3
|
-
var DISCOVERY_CHANNEL = "colyseus:nodes:discovery";
|
|
4
|
-
async function getHostname() {
|
|
5
|
-
return process.env.SELF_HOSTNAME;
|
|
6
|
-
}
|
|
7
|
-
async function getNodeAddress(node) {
|
|
8
|
-
const host = await getHostname();
|
|
9
|
-
const port = process.env.SELF_PORT ?? node.port;
|
|
10
|
-
return port ? `${node.processId}/${host}:${port}` : `${node.processId}/${host}`;
|
|
11
|
-
}
|
|
12
|
-
async function registerNode(presence, node) {
|
|
13
|
-
const nodeAddress = await getNodeAddress(node);
|
|
14
|
-
await presence.sadd(NODES_SET, nodeAddress);
|
|
15
|
-
await presence.publish(DISCOVERY_CHANNEL, `add,${nodeAddress}`);
|
|
16
|
-
}
|
|
17
|
-
async function unregisterNode(presence, node) {
|
|
18
|
-
const nodeAddress = await getNodeAddress(node);
|
|
19
|
-
await presence.srem(NODES_SET, nodeAddress);
|
|
20
|
-
await presence.publish(DISCOVERY_CHANNEL, `remove,${nodeAddress}`);
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
getHostname,
|
|
24
|
-
registerNode,
|
|
25
|
-
unregisterNode
|
|
26
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/discovery/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { Presence } from '../presence/Presence.js';\n\nconst NODES_SET = 'colyseus:nodes';\nconst DISCOVERY_CHANNEL = 'colyseus:nodes:discovery';\n\nexport interface Node {\n port: number;\n processId: string;\n}\n\nexport async function getHostname() {\n return process.env.SELF_HOSTNAME;\n}\n\nasync function getNodeAddress(node: Node) {\n const host = await getHostname();\n const port = process.env.SELF_PORT ?? node.port;\n return (port)\n ? `${node.processId}/${host}:${port}`\n : `${node.processId}/${host}`;\n}\n\nexport async function registerNode(presence: Presence, node: Node) {\n const nodeAddress = await getNodeAddress(node);\n await presence.sadd(NODES_SET, nodeAddress);\n await presence.publish(DISCOVERY_CHANNEL, `add,${nodeAddress}`);\n}\n\nexport async function unregisterNode(presence: Presence, node: Node) {\n const nodeAddress = await getNodeAddress(node);\n await presence.srem(NODES_SET, nodeAddress);\n await presence.publish(DISCOVERY_CHANNEL, `remove,${nodeAddress}`);\n}\n"],
|
|
5
|
-
"mappings": ";AAEA,IAAM,YAAY;AAClB,IAAM,oBAAoB;AAO1B,eAAsB,cAAc;AAClC,SAAO,QAAQ,IAAI;AACrB;AAEA,eAAe,eAAe,MAAY;AACxC,QAAM,OAAO,MAAM,YAAY;AAC/B,QAAM,OAAO,QAAQ,IAAI,aAAa,KAAK;AAC3C,SAAQ,OACJ,GAAG,KAAK,SAAS,IAAI,IAAI,IAAI,IAAI,KACjC,GAAG,KAAK,SAAS,IAAI,IAAI;AAC/B;AAEA,eAAsB,aAAa,UAAoB,MAAY;AACjE,QAAM,cAAc,MAAM,eAAe,IAAI;AAC7C,QAAM,SAAS,KAAK,WAAW,WAAW;AAC1C,QAAM,SAAS,QAAQ,mBAAmB,OAAO,WAAW,EAAE;AAChE;AAEA,eAAsB,eAAe,UAAoB,MAAY;AACnE,QAAM,cAAc,MAAM,eAAe,IAAI;AAC7C,QAAM,SAAS,KAAK,WAAW,WAAW;AAC1C,QAAM,SAAS,QAAQ,mBAAmB,UAAU,WAAW,EAAE;AACnE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/build/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import Clock, { Delayed } from '@colyseus/timer';
|
|
2
|
-
export { Server, type ServerOptions } from './Server.js';
|
|
3
|
-
export { Room, RoomInternalState } from './Room.js';
|
|
4
|
-
export { Protocol, ErrorCode, getMessageBytes } from './Protocol.js';
|
|
5
|
-
export { RegisteredHandler } from './matchmaker/RegisteredHandler.js';
|
|
6
|
-
export { ServerError } from './errors/ServerError.js';
|
|
7
|
-
export { type RoomException, OnCreateException, OnAuthException, OnJoinException, OnLeaveException, OnDisposeException, OnMessageException, SimulationIntervalException, TimedEventException, } from './errors/RoomExceptions.js';
|
|
8
|
-
import * as matchMaker from './MatchMaker.js';
|
|
9
|
-
export { matchMaker };
|
|
10
|
-
export { updateLobby, subscribeLobby } from './matchmaker/Lobby.js';
|
|
11
|
-
export * from './matchmaker/driver/local/LocalDriver.js';
|
|
12
|
-
export { type Client, type ClientPrivate, type AuthContext, ClientState, ClientArray, Transport, type ISendOptions } from './Transport.js';
|
|
13
|
-
export { type Presence } from './presence/Presence.js';
|
|
14
|
-
export { LocalPresence } from './presence/LocalPresence.js';
|
|
15
|
-
export { type Serializer } from './serializer/Serializer.js';
|
|
16
|
-
export { SchemaSerializer } from './serializer/SchemaSerializer.js';
|
|
17
|
-
export { Clock, Delayed };
|
|
18
|
-
export { generateId, Deferred, HttpServerMock, spliceOne, getBearerToken } from './utils/Utils.js';
|
|
19
|
-
export { isDevMode } from './utils/DevMode.js';
|
|
20
|
-
export { subscribeIPC, requestFromIPC } from './IPC.js';
|
|
21
|
-
export { debugMatchMaking, debugMessage, debugPatch, debugError, debugConnection, debugDriver, debugPresence, debugAndPrintError, } from './Debug.js';
|
|
22
|
-
export { LobbyRoom } from './rooms/LobbyRoom.js';
|
|
23
|
-
export { RelayRoom } from './rooms/RelayRoom.js';
|
|
24
|
-
export { logger } from './Logger.js';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Room } from '../Room.js';
|
|
2
|
-
import { IRoomCache } from './driver/api.js';
|
|
3
|
-
export declare function updateLobby(room: Room, removed?: boolean): void;
|
|
4
|
-
export declare function subscribeLobby(callback: (roomId: string, roomListing: IRoomCache) => void): Promise<() => any>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage } from 'http';
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import { RoomCache, SortOptions } from './driver/api.js';
|
|
4
|
-
import { Room } from './../Room.js';
|
|
5
|
-
import { Type } from '../utils/types.js';
|
|
6
|
-
export declare const INVALID_OPTION_KEYS: Array<keyof RoomCache>;
|
|
7
|
-
export type ValidateAuthTokenCallback = (token: string, request?: IncomingMessage) => Promise<any>;
|
|
8
|
-
export declare class RegisteredHandler extends EventEmitter {
|
|
9
|
-
name: string;
|
|
10
|
-
klass: Type<Room>;
|
|
11
|
-
options: any;
|
|
12
|
-
filterOptions: string[];
|
|
13
|
-
sortOptions?: SortOptions;
|
|
14
|
-
constructor(name: string, klass: Type<Room>, options: any);
|
|
15
|
-
enableRealtimeListing(): this;
|
|
16
|
-
filterBy(options: string[]): this;
|
|
17
|
-
sortBy(options: SortOptions): this;
|
|
18
|
-
getFilterOptions(options: any): {};
|
|
19
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { QueryHelpers, SortOptions } from './interfaces';
|
|
2
|
-
export declare class Query<T> implements QueryHelpers<T> {
|
|
3
|
-
private $rooms;
|
|
4
|
-
private conditions;
|
|
5
|
-
constructor(rooms: any[], conditions: any);
|
|
6
|
-
sort(options: SortOptions): void;
|
|
7
|
-
then(resolve: any, reject: any): any;
|
|
8
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var Query_exports = {};
|
|
19
|
-
__export(Query_exports, {
|
|
20
|
-
Query: () => Query
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(Query_exports);
|
|
23
|
-
class Query {
|
|
24
|
-
constructor(rooms, conditions) {
|
|
25
|
-
this.$rooms = rooms.slice(0);
|
|
26
|
-
this.conditions = conditions;
|
|
27
|
-
}
|
|
28
|
-
sort(options) {
|
|
29
|
-
this.$rooms = this.$rooms.sort((room1, room2) => {
|
|
30
|
-
for (const field in options) {
|
|
31
|
-
if (options.hasOwnProperty(field)) {
|
|
32
|
-
const direction = options[field];
|
|
33
|
-
const isAscending = direction === 1 || direction === "asc" || direction === "ascending";
|
|
34
|
-
if (isAscending) {
|
|
35
|
-
if (room1[field] > room2[field]) {
|
|
36
|
-
return 1;
|
|
37
|
-
}
|
|
38
|
-
if (room1[field] < room2[field]) {
|
|
39
|
-
return -1;
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
if (room1[field] > room2[field]) {
|
|
43
|
-
return -1;
|
|
44
|
-
}
|
|
45
|
-
if (room1[field] < room2[field]) {
|
|
46
|
-
return 1;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
then(resolve, reject) {
|
|
54
|
-
const result = this.$rooms.find((room) => {
|
|
55
|
-
for (const field in this.conditions) {
|
|
56
|
-
if (this.conditions.hasOwnProperty(field) && room[field] !== this.conditions[field]) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
61
|
-
});
|
|
62
|
-
return resolve(result);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
-
0 && (module.exports = {
|
|
67
|
-
Query
|
|
68
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/matchmaker/driver/Query.ts"],
|
|
4
|
-
"sourcesContent": ["import { QueryHelpers, SortOptions } from './interfaces';\n\nexport class Query<T> implements QueryHelpers<T> {\n private $rooms: T[];\n private conditions: any;\n\n constructor(rooms: any[], conditions) {\n this.$rooms = rooms.slice(0);\n this.conditions = conditions;\n }\n\n public sort(options: SortOptions) {\n this.$rooms = this.$rooms.sort((room1, room2) => {\n for (const field in options) {\n if (options.hasOwnProperty(field)) {\n const direction = options[field];\n const isAscending = (direction === 1 || direction === 'asc' || direction === 'ascending');\n\n if (isAscending) {\n if (room1[field] > room2[field]) { return 1; }\n if (room1[field] < room2[field]) { return -1; }\n\n } else {\n if (room1[field] > room2[field]) { return -1; }\n if (room1[field] < room2[field]) { return 1; }\n }\n }\n }\n });\n }\n\n public then(resolve, reject) {\n const result: any = this.$rooms.find(((room) => {\n for (const field in this.conditions) {\n if (\n this.conditions.hasOwnProperty(field) &&\n room[field] !== this.conditions[field]\n ) {\n return false;\n }\n }\n return true;\n }));\n return resolve(result);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,MAAoC;AAAA,EAI/C,YAAY,OAAc,YAAY;AACpC,SAAK,SAAS,MAAM,MAAM,CAAC;AAC3B,SAAK,aAAa;AAAA,EACpB;AAAA,EAEO,KAAK,SAAsB;AAChC,SAAK,SAAS,KAAK,OAAO,KAAK,CAAC,OAAO,UAAU;AAC/C,iBAAW,SAAS,SAAS;AAC3B,YAAI,QAAQ,eAAe,KAAK,GAAG;AACjC,gBAAM,YAAY,QAAQ;AAC1B,gBAAM,cAAe,cAAc,KAAK,cAAc,SAAS,cAAc;AAE7E,cAAI,aAAa;AACf,gBAAI,MAAM,SAAS,MAAM,QAAQ;AAAE,qBAAO;AAAA,YAAG;AAC7C,gBAAI,MAAM,SAAS,MAAM,QAAQ;AAAE,qBAAO;AAAA,YAAI;AAAA,UAEhD,OAAO;AACL,gBAAI,MAAM,SAAS,MAAM,QAAQ;AAAE,qBAAO;AAAA,YAAI;AAC9C,gBAAI,MAAM,SAAS,MAAM,QAAQ;AAAE,qBAAO;AAAA,YAAG;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEO,KAAK,SAAS,QAAQ;AAC3B,UAAM,SAAc,KAAK,OAAO,KAAM,CAAC,SAAS;AAC9C,iBAAW,SAAS,KAAK,YAAY;AACnC,YACE,KAAK,WAAW,eAAe,KAAK,KACpC,KAAK,WAAW,KAAK,WAAW,QAChC;AACA,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAE;AACF,WAAO,QAAQ,MAAM;AAAA,EACvB;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
class Query {
|
|
2
|
-
constructor(rooms, conditions) {
|
|
3
|
-
this.$rooms = rooms.slice(0);
|
|
4
|
-
this.conditions = conditions;
|
|
5
|
-
}
|
|
6
|
-
sort(options) {
|
|
7
|
-
this.$rooms = this.$rooms.sort((room1, room2) => {
|
|
8
|
-
for (const field in options) {
|
|
9
|
-
if (options.hasOwnProperty(field)) {
|
|
10
|
-
const direction = options[field];
|
|
11
|
-
const isAscending = direction === 1 || direction === "asc" || direction === "ascending";
|
|
12
|
-
if (isAscending) {
|
|
13
|
-
if (room1[field] > room2[field]) {
|
|
14
|
-
return 1;
|
|
15
|
-
}
|
|
16
|
-
if (room1[field] < room2[field]) {
|
|
17
|
-
return -1;
|
|
18
|
-
}
|
|
19
|
-
} else {
|
|
20
|
-
if (room1[field] > room2[field]) {
|
|
21
|
-
return -1;
|
|
22
|
-
}
|
|
23
|
-
if (room1[field] < room2[field]) {
|
|
24
|
-
return 1;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
then(resolve, reject) {
|
|
32
|
-
const result = this.$rooms.find((room) => {
|
|
33
|
-
for (const field in this.conditions) {
|
|
34
|
-
if (this.conditions.hasOwnProperty(field) && room[field] !== this.conditions[field]) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return true;
|
|
39
|
-
});
|
|
40
|
-
return resolve(result);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export {
|
|
44
|
-
Query
|
|
45
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/matchmaker/driver/Query.ts"],
|
|
4
|
-
"sourcesContent": ["import { QueryHelpers, SortOptions } from './interfaces';\n\nexport class Query<T> implements QueryHelpers<T> {\n private $rooms: T[];\n private conditions: any;\n\n constructor(rooms: any[], conditions) {\n this.$rooms = rooms.slice(0);\n this.conditions = conditions;\n }\n\n public sort(options: SortOptions) {\n this.$rooms = this.$rooms.sort((room1, room2) => {\n for (const field in options) {\n if (options.hasOwnProperty(field)) {\n const direction = options[field];\n const isAscending = (direction === 1 || direction === 'asc' || direction === 'ascending');\n\n if (isAscending) {\n if (room1[field] > room2[field]) { return 1; }\n if (room1[field] < room2[field]) { return -1; }\n\n } else {\n if (room1[field] > room2[field]) { return -1; }\n if (room1[field] < room2[field]) { return 1; }\n }\n }\n }\n });\n }\n\n public then(resolve, reject) {\n const result: any = this.$rooms.find(((room) => {\n for (const field in this.conditions) {\n if (\n this.conditions.hasOwnProperty(field) &&\n room[field] !== this.conditions[field]\n ) {\n return false;\n }\n }\n return true;\n }));\n return resolve(result);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAEO,MAAM,MAAoC;AAAA,EAI/C,YAAY,OAAc,YAAY;AACpC,SAAK,SAAS,MAAM,MAAM,CAAC;AAC3B,SAAK,aAAa;AAAA,EACpB;AAAA,EAEO,KAAK,SAAsB;AAChC,SAAK,SAAS,KAAK,OAAO,KAAK,CAAC,OAAO,UAAU;AAC/C,iBAAW,SAAS,SAAS;AAC3B,YAAI,QAAQ,eAAe,KAAK,GAAG;AACjC,gBAAM,YAAY,QAAQ;AAC1B,gBAAM,cAAe,cAAc,KAAK,cAAc,SAAS,cAAc;AAE7E,cAAI,aAAa;AACf,gBAAI,MAAM,SAAS,MAAM,QAAQ;AAAE,qBAAO;AAAA,YAAG;AAC7C,gBAAI,MAAM,SAAS,MAAM,QAAQ;AAAE,qBAAO;AAAA,YAAI;AAAA,UAEhD,OAAO;AACL,gBAAI,MAAM,SAAS,MAAM,QAAQ;AAAE,qBAAO;AAAA,YAAI;AAC9C,gBAAI,MAAM,SAAS,MAAM,QAAQ;AAAE,qBAAO;AAAA,YAAG;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEO,KAAK,SAAS,QAAQ;AAC3B,UAAM,SAAc,KAAK,OAAO,KAAM,CAAC,SAAS;AAC9C,iBAAW,SAAS,KAAK,YAAY;AACnC,YACE,KAAK,WAAW,eAAe,KAAK,KACpC,KAAK,WAAW,KAAK,WAAW,QAChC;AACA,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAE;AACF,WAAO,QAAQ,MAAM;AAAA,EACvB;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { RoomListingData } from './interfaces';
|
|
2
|
-
export declare class RoomCache implements RoomListingData {
|
|
3
|
-
clients: number;
|
|
4
|
-
locked: boolean;
|
|
5
|
-
private: boolean;
|
|
6
|
-
maxClients: number;
|
|
7
|
-
metadata: any;
|
|
8
|
-
name: string;
|
|
9
|
-
publicAddress: string;
|
|
10
|
-
processId: string;
|
|
11
|
-
roomId: string;
|
|
12
|
-
createdAt: Date;
|
|
13
|
-
unlisted: boolean;
|
|
14
|
-
private $rooms;
|
|
15
|
-
constructor(initialValues: any, rooms: RoomCache[]);
|
|
16
|
-
save(): void;
|
|
17
|
-
updateOne(operations: any): void;
|
|
18
|
-
remove(): void;
|
|
19
|
-
}
|