redweb 0.7.2 → 0.7.3
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 -2
- package/package.json +2 -2
- package/src/ws/BaseSocketServer.js +15 -1
package/README.md
CHANGED
|
@@ -217,7 +217,6 @@ Useful for managing players, NPCs, chat members, rooms, etc.
|
|
|
217
217
|
### 🔧 Basic Usage
|
|
218
218
|
|
|
219
219
|
```js
|
|
220
|
-
const { SocketRegistry } = require('redweb');
|
|
221
220
|
|
|
222
221
|
class Player {
|
|
223
222
|
constructor(socket, id) {
|
|
@@ -351,4 +350,4 @@ Here’s the updated `CHANGELOG.md` entry for **RedWeb v0.7.1**, written profess
|
|
|
351
350
|
|
|
352
351
|
## 🪪 License
|
|
353
352
|
|
|
354
|
-
MIT
|
|
353
|
+
MIT
|
package/package.json
CHANGED
|
@@ -34,7 +34,21 @@ class BaseSocketServer {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
handleUpgrade(req, sock, head) {
|
|
37
|
-
|
|
37
|
+
// Some websocket clients (e.g., certain UE plugins) are finicky about the
|
|
38
|
+
// HTTP upgrade path they send. Normalise the path and fall back to a default
|
|
39
|
+
// route so we can still complete the upgrade instead of tearing the socket down.
|
|
40
|
+
const path = (() => {
|
|
41
|
+
try {
|
|
42
|
+
return new URL(req.url, `http://${req.headers.host || 'localhost'}`).pathname;
|
|
43
|
+
} catch {
|
|
44
|
+
return req.url;
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
|
|
48
|
+
const route =
|
|
49
|
+
this.routes.find(r => r.path === path) ||
|
|
50
|
+
this.routes.find(r => r.path === '/');
|
|
51
|
+
|
|
38
52
|
if (!route) return sock.destroy();
|
|
39
53
|
|
|
40
54
|
route.server.handleUpgrade(req, sock, head, (s, r) =>
|