playsocketjs 2.2.1 → 2.2.2
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/README.md +1 -1
- package/dist/playsocket-server.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -221,7 +221,7 @@ Creates a new PlaySocket Server instance with configuration options.
|
|
|
221
221
|
- `clientJoinedRoom`: Client joined a room – note that clients can only leave by disconnecting (returns the client's ID `string`, room ID `string`)
|
|
222
222
|
- `roomCreated`: Client created a room (returns room ID `string`)
|
|
223
223
|
- `roomDestroyed`: Room was destroyed, this happens when all participants leave (returns room ID `string`)
|
|
224
|
-
- `roomCreationRequested`: Room creation requested by client (returns `object` containing the client's ID `string`, room ID `string` and the initialStorage `object`) – if you return an `object` in the callback, it will take that as the initial storage instead
|
|
224
|
+
- `roomCreationRequested`: Room creation requested by client (returns `object` containing the client's ID `string`, room ID `string` and the initialStorage `object`) – if you return an `object` in the callback, it will take that as the initial storage instead. If you return `false`, the creation will be denied
|
|
225
225
|
- `storageUpdateRequested`: Room storage property update requested by client (returns `object` containing the client's ID `string`, room ID `string` and the update `object`) – if you return `false` in the callback, the update will be blocked
|
|
226
226
|
- `requestReceived`: Request from client was received by the server (returns `object` containing client's ID `string`, if in room – room ID `string`, request name `string` and optional passed data of type `any`)
|
|
227
227
|
|
|
@@ -2399,6 +2399,13 @@ function requireServer () {
|
|
|
2399
2399
|
// Event callback with potential initial storage modifications
|
|
2400
2400
|
const reviewedStorage = await this.#triggerEvent("roomCreationRequested", { roomId: newRoomId, clientId: ws.clientId, initialStorage: structuredClone({ ...data.initialStorage }) });
|
|
2401
2401
|
if (typeof reviewedStorage === 'object') data.initialStorage = reviewedStorage;
|
|
2402
|
+
if (reviewedStorage === false) {
|
|
2403
|
+
ws.send(encode({
|
|
2404
|
+
type: 'room_creation_failed',
|
|
2405
|
+
reason: 'Room creation denied.'
|
|
2406
|
+
}), { binary: true });
|
|
2407
|
+
return;
|
|
2408
|
+
}
|
|
2402
2409
|
|
|
2403
2410
|
// Check if client/creator is still connected
|
|
2404
2411
|
if (!this.#clients.has(ws.clientId)) {
|