playsocketjs 2.4.2 → 2.5.1
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 +3 -2
- package/dist/playsocket-client.js +383 -395
- package/dist/{playsocket-server.js → playsocket-server.cjs} +967 -1072
- package/dist/playsocket-server.mjs +2646 -0
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ new PlaySocket(id?: string, options: PlaySocketOptions)
|
|
|
96
96
|
### Methods
|
|
97
97
|
|
|
98
98
|
- `init()`: Initialize the WebSocket connection – Returns Promise (async) which resolves with the client's ID
|
|
99
|
-
- `createRoom(initialStorage?: object, maxSize?: number)`: Create a new room and become host – Returns Promise (async) which resolves with the room ID
|
|
99
|
+
- `createRoom(initialStorage?: object, maxSize?: number)`: Create a new room and become host – Returns Promise (async) which resolves with the room ID. The room participant maximum is 100
|
|
100
100
|
- `joinRoom(hostId: string)`: Join an existing room – Returns Promise (async)
|
|
101
101
|
- `destroy()`: Use this to leave a room and close the connection
|
|
102
102
|
- `updateStorage(key: string, type: 'set' | 'array-add' | 'array-add-unique' | 'array-remove-matching' | 'array-update-matching', value: any, updateValue?: any)`: Update the shared storage (max. 100 keys). Safely update arrays in storage by adding, removing, or updating items. UpdateValue is only required for the 'array-update-matching' operation type
|
|
@@ -141,7 +141,7 @@ Here are usage examples for a standalone server and an Express.js application.
|
|
|
141
141
|
### Standalone server
|
|
142
142
|
|
|
143
143
|
```javascript
|
|
144
|
-
|
|
144
|
+
import PlaySocketServer from 'playsocketjs/server'; // Both ES Module & CommonJS Module syntax is supported
|
|
145
145
|
|
|
146
146
|
const server = new PlaySocketServer(); // Create and start the server (default path is /socket)
|
|
147
147
|
|
|
@@ -203,6 +203,7 @@ Creates a new PlaySocket Server instance with configuration options.
|
|
|
203
203
|
- `port`: Port to listen on (default: 3000, used only if no server provided)
|
|
204
204
|
- `path`: WebSocket endpoint path (default: '/')
|
|
205
205
|
- `server`: Existing http server (optional)
|
|
206
|
+
- `rateLimit`: Adjust the messages/second rate limit (defaults to 20)
|
|
206
207
|
- `debug`: Set this property to true to enable extra logging
|
|
207
208
|
|
|
208
209
|
### Methods
|