@colyseus/core 0.18.25 → 0.18.26
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/Room.cjs +9 -3
- package/build/Room.cjs.map +2 -2
- package/build/Room.d.ts +33 -0
- package/build/Room.mjs +9 -3
- package/build/Room.mjs.map +2 -2
- package/build/RoomMessages.cjs +31 -2
- package/build/RoomMessages.cjs.map +2 -2
- package/build/RoomMessages.d.ts +2 -2
- package/build/RoomMessages.mjs +31 -2
- package/build/RoomMessages.mjs.map +2 -2
- package/package.json +3 -3
- package/src/Room.ts +45 -5
- package/src/RoomMessages.ts +41 -4
package/build/Room.cjs
CHANGED
|
@@ -87,6 +87,8 @@ var Room = class _Room {
|
|
|
87
87
|
*/
|
|
88
88
|
this.clock = new import_timer.ClockTimer();
|
|
89
89
|
this.#_onLeaveConcurrent = 0;
|
|
90
|
+
// number of onLeave calls in progress
|
|
91
|
+
this.#_pendingCloses = /* @__PURE__ */ new WeakMap();
|
|
90
92
|
this.#_maxClientsReached = false;
|
|
91
93
|
this.#_maxClients = Infinity;
|
|
92
94
|
this.#_autoDispose = true;
|
|
@@ -188,6 +190,7 @@ var Room = class _Room {
|
|
|
188
190
|
#_roomId;
|
|
189
191
|
#_roomName;
|
|
190
192
|
#_onLeaveConcurrent;
|
|
193
|
+
#_pendingCloses;
|
|
191
194
|
#_maxClientsReached;
|
|
192
195
|
#_maxClients;
|
|
193
196
|
#_autoDispose;
|
|
@@ -1226,6 +1229,7 @@ var Room = class _Room {
|
|
|
1226
1229
|
return this._reconnections[reconnectionToken][1];
|
|
1227
1230
|
}
|
|
1228
1231
|
this._reserveSeat(sessionId, true, previousClient.auth, seconds, true);
|
|
1232
|
+
this.#_pendingCloses.get(previousClient)?.();
|
|
1229
1233
|
const reconnection = new import_Utils.Deferred();
|
|
1230
1234
|
this._reconnections[reconnectionToken] = [sessionId, reconnection];
|
|
1231
1235
|
if (seconds !== Infinity) {
|
|
@@ -1468,11 +1472,13 @@ var Room = class _Room {
|
|
|
1468
1472
|
client.ref.removeAllListeners("message");
|
|
1469
1473
|
client.ref.removeListener("close", client.ref["onleave"]);
|
|
1470
1474
|
const ref = client.ref;
|
|
1471
|
-
|
|
1472
|
-
if (client.ref === ref) {
|
|
1475
|
+
const close = () => {
|
|
1476
|
+
if (this.#_pendingCloses.delete(client) && client.ref === ref) {
|
|
1473
1477
|
client.leave(closeCode, reason);
|
|
1474
1478
|
}
|
|
1475
|
-
}
|
|
1479
|
+
};
|
|
1480
|
+
this.#_pendingCloses.set(client, close);
|
|
1481
|
+
this._onLeave(client, closeCode).then(close);
|
|
1476
1482
|
}
|
|
1477
1483
|
async _onLeave(client, code) {
|
|
1478
1484
|
const method = code === import_shared_types.CloseCode.CONSENTED || client.state === import_Transport.ClientState.RECONNECTING ? this.onLeave : this.onDrop || this.onLeave;
|