@colyseus/core
Advanced tools
Comparing version 0.16.0-alpha.25 to 0.16.0-alpha.26
@@ -138,6 +138,12 @@ var __create = Object.create; | ||
await concurrentJoinOrCreateRoomLock(handler, concurrencyKey, async (roomId) => { | ||
room = roomId ? await driver.findOne({ roomId }) : await findOneRoomAvailable(roomName, clientOptions); | ||
if (roomId) { | ||
room = await driver.findOne({ roomId }); | ||
} | ||
if (!room) { | ||
room = await findOneRoomAvailable(roomName, clientOptions); | ||
} | ||
if (!room) { | ||
room = await createRoom(roomName, clientOptions); | ||
presence.lpush(`l:${handler.name}:${concurrencyKey}`, room.roomId); | ||
presence.expire(`l:${handler.name}:${concurrencyKey}`, import_Utils.MAX_CONCURRENT_CREATE_ROOM_WAIT_TIME * 2); | ||
} | ||
@@ -144,0 +150,0 @@ return room; |
@@ -28,2 +28,3 @@ import { EventEmitter } from 'events'; | ||
setex(key: string, value: string, seconds: number): void; | ||
expire(key: string, seconds: number): void; | ||
get(key: string): string | number; | ||
@@ -30,0 +31,0 @@ del(key: string): void; |
@@ -96,6 +96,9 @@ var __create = Object.create; | ||
setex(key, value, seconds) { | ||
this.keys[key] = value; | ||
this.expire(key, seconds); | ||
} | ||
expire(key, seconds) { | ||
if (this.timeouts[key]) { | ||
clearTimeout(this.timeouts[key]); | ||
} | ||
this.keys[key] = value; | ||
this.timeouts[key] = setTimeout(() => { | ||
@@ -102,0 +105,0 @@ delete this.keys[key]; |
@@ -56,2 +56,9 @@ /** | ||
/** | ||
* Expire the key in seconds. | ||
* | ||
* @param key - Identifier. | ||
* @param seconds - Seconds to expire the key. | ||
*/ | ||
expire(key: string, seconds: number): any; | ||
/** | ||
* Get the value of key. | ||
@@ -58,0 +65,0 @@ * |
{ | ||
"name": "@colyseus/core", | ||
"version": "0.16.0-alpha.25", | ||
"version": "0.16.0-alpha.26", | ||
"description": "Multiplayer Framework for Node.js.", | ||
@@ -5,0 +5,0 @@ "input": "./src/index.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
711986
8025