@stonyx/sockets 0.1.1-alpha.38 → 0.1.1-alpha.39

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.
Files changed (2) hide show
  1. package/README.md +19 -1
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -15,6 +15,17 @@ WebSocket server and client module for the [Stonyx framework](https://github.com
15
15
  * **Encryption by default:** AES-256-GCM with per-session keys, zero external dependencies.
16
16
  * **Singleton pattern:** Matches the conventions of `@stonyx/rest-server` and `stonyx-orm`.
17
17
 
18
+ ## Usage reference
19
+
20
+ The handlers in [`test/sample/`](https://github.com/abofs/stonyx-sockets/tree/dev/test/sample) are the canonical usage reference for this module; the integration tests run against them. They are not included in the npm package.
21
+
22
+ Exports:
23
+
24
+ * `@stonyx/sockets`: named `SocketServer`, `SocketClient` and `Handler`; the default export is the `Sockets` class Stonyx uses for auto-init
25
+ * `@stonyx/sockets/server`: `SocketServer`
26
+ * `@stonyx/sockets/client`: `SocketClient`
27
+ * `@stonyx/sockets/handler`: `Handler`
28
+
18
29
  ## Installation
19
30
 
20
31
  ```bash
@@ -210,6 +221,10 @@ Configuration is read from `stonyx/config` under `sockets`:
210
221
  | `heartBeatInterval` | `SOCKET_HEARTBEAT_INTERVAL` | `30000` | Heartbeat interval in ms |
211
222
  | `handlerDir` | `SOCKET_HANDLER_DIR` | `'./socket-handlers'` | Handler directory path |
212
223
  | `encryption` | `SOCKET_ENCRYPTION` | `'true'` | Enable AES-256-GCM encryption |
224
+ | `authData` | — | `{}` | Extra fields sent with `authKey` in the auth request |
225
+ | `reconnectBaseDelay` | `SOCKET_RECONNECT_BASE_DELAY` | `1000` | First reconnect delay in ms (doubles per attempt) |
226
+ | `reconnectMaxDelay` | `SOCKET_RECONNECT_MAX_DELAY` | `60000` | Reconnect delay cap in ms |
227
+ | `maxReconnectAttempts` | `SOCKET_MAX_RECONNECT_ATTEMPTS` | `Infinity` | Attempts before `onReconnectFailed` |
213
228
 
214
229
  ## API Reference
215
230
 
@@ -220,7 +235,9 @@ Configuration is read from `stonyx/config` under `sockets`:
220
235
  | `new SocketServer()` | Singleton constructor |
221
236
  | `async init()` | Discover handlers, validate auth, start WebSocket server |
222
237
  | `sendTo(clientId, request, data)` | Send to one client by ID |
238
+ | `sendToByMeta(key, value, request, data)` | Send to the first authenticated client whose `meta[key] === value`; returns `true`/`false` |
223
239
  | `broadcast(request, data)` | Send to all authenticated clients |
240
+ | `onClientDisconnect` | Optional `(client, code, reason)` callback |
224
241
  | `clientMap` | `Map<id, client>` of connected clients |
225
242
  | `close()` | Terminate all connections and stop the server |
226
243
  | `reset()` | Close + clear all state (for testing) |
@@ -233,7 +250,8 @@ Configuration is read from `stonyx/config` under `sockets`:
233
250
  | `async init()` | Discover handlers, connect, authenticate |
234
251
  | `send(payload)` | Send a message to the server |
235
252
  | `close()` | Forcefully tear down the socket (remove listeners, terminate, null) |
236
- | `reconnect()` | Reconnect (max 5 retries) |
253
+ | `reconnect()` | Reconnect with exponential backoff, up to `maxReconnectAttempts` (unlimited by default) |
254
+ | `onDisconnect`, `onReconnecting`, `onReconnected`, `onReconnectFailed` | Optional lifecycle callbacks |
237
255
  | `reset()` | Close + clear all state (for testing) |
238
256
 
239
257
  ### Handler
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "stonyx-async",
5
5
  "stonyx-module"
6
6
  ],
7
- "version": "0.1.1-alpha.38",
7
+ "version": "0.1.1-alpha.39",
8
8
  "description": "WebSocket server and client module for the Stonyx framework",
9
9
  "main": "dist/main.js",
10
10
  "types": "dist/main.d.ts",
@@ -51,11 +51,11 @@
51
51
  },
52
52
  "homepage": "https://github.com/abofs/stonyx-sockets#readme",
53
53
  "dependencies": {
54
- "stonyx": "0.2.3-beta.62",
54
+ "stonyx": "0.2.3-beta.98",
55
55
  "ws": "^8.18.1"
56
56
  },
57
57
  "devDependencies": {
58
- "@stonyx/utils": "0.2.3-beta.23",
58
+ "@stonyx/utils": "0.2.3-beta.27",
59
59
  "@types/node": "^25.5.2",
60
60
  "@types/ws": "^8.18.1",
61
61
  "qunit": "^2.24.1",