openportal 0.1.1 → 0.1.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 +113 -0
- package/package.json +1 -1
- package/web/.next/static/{A7pW-dtFIbPCSkvE8uenX → Im7EdK1Q3oOmTznohTOr5}/_buildManifest.js +4 -9
- package/web/.next/static/chunks/{2e7bfb90c343ca96.js → 35cc9dbdc670c73c.js} +4 -4
- package/web/.next/static/chunks/4147ffc67a7b837c.css +1 -0
- package/web/.next/static/chunks/{21ab2574b84ad2d1.js → 52b90bc1740162c2.js} +2 -2
- package/web/.next/static/chunks/{9b265e2198b5525f.js → 8644d68bf325ff24.js} +3 -3
- package/web/.next/static/chunks/{03e1846335a31354.js → 9865709466b09f79.js} +3 -3
- package/web/.next/static/chunks/{c20ae04df8cc28be.js → 9ba9a5774c9421bd.js} +3 -3
- package/web/.next/static/chunks/{967a1e0002fe9ae6.js → b5caad256518cb33.js} +3 -3
- package/web/.next/static/chunks/{turbopack-27558c851386934e.js → turbopack-26af71e419c11487.js} +1 -1
- package/web/.next/static/chunks/{turbopack-f4c0881f9723f5a5.js → turbopack-4ad0df7330c00c8d.js} +1 -1
- package/web/.next/static/chunks/{turbopack-26688626142ac58f.js → turbopack-8e653f3ad3a8ed18.js} +1 -1
- package/web/.next/static/chunks/{turbopack-c40ec6674624f1d7.js → turbopack-d5098189d63fd7b8.js} +1 -1
- package/web/apps/web/.next/BUILD_ID +1 -1
- package/web/apps/web/.next/build-manifest.json +14 -24
- package/web/apps/web/.next/routes-manifest.json +0 -12
- package/web/apps/web/.next/server/chunks/[root-of-the-server]__f366ca98._.js +358 -0
- package/web/apps/web/.next/server/chunks/ssr/{[root-of-the-server]__dfeaf8cf._.js → [root-of-the-server]__1a54ba1e._.js} +3 -3
- package/web/apps/web/.next/server/middleware-build-manifest.js +12 -22
- package/web/apps/web/.next/server/next-font-manifest.js +1 -1
- package/web/apps/web/.next/server/next-font-manifest.json +0 -4
- package/web/apps/web/.next/server/pages/404.html +1 -1
- package/web/apps/web/.next/server/pages/500.html +1 -1
- package/web/apps/web/.next/server/pages/_app/build-manifest.json +3 -3
- package/web/apps/web/.next/server/pages/_app/client-build-manifest.json +1 -1
- package/web/apps/web/.next/server/pages/api/[[...slugs]].js +1 -2
- package/web/apps/web/.next/server/pages/api/[[...slugs]].js.nft.json +1 -1
- package/web/apps/web/.next/server/pages/index/build-manifest.json +3 -3
- package/web/apps/web/.next/server/pages/index/client-build-manifest.json +1 -1
- package/web/apps/web/.next/server/pages/index.html +1 -1
- package/web/apps/web/.next/server/pages/index.js.nft.json +1 -1
- package/web/apps/web/.next/server/pages/session/[id]/build-manifest.json +4 -4
- package/web/apps/web/.next/server/pages/session/[id]/client-build-manifest.json +1 -1
- package/web/apps/web/.next/server/pages/session/[id].html +1 -1
- package/web/apps/web/.next/server/pages/session/[id].js.nft.json +1 -1
- package/web/apps/web/.next/server/pages/settings/build-manifest.json +3 -3
- package/web/apps/web/.next/server/pages/settings/client-build-manifest.json +1 -1
- package/web/apps/web/.next/server/pages/settings.html +1 -1
- package/web/apps/web/.next/server/pages/settings.js.nft.json +1 -1
- package/web/apps/web/.next/server/pages-manifest.json +0 -2
- package/web/apps/web/package.json +1 -9
- package/web/.next/static/chunks/04d4692d75696297.css +0 -1
- package/web/.next/static/chunks/553710f60e2f2b11.js +0 -1
- package/web/.next/static/chunks/58acbbb4090e3362.js +0 -3
- package/web/.next/static/chunks/6ce1e2f08f961db5.js +0 -2
- package/web/.next/static/chunks/d316d63225992c76.js +0 -10
- package/web/.next/static/chunks/e0c97552ba7a9e3d.js +0 -1
- package/web/.next/static/chunks/fc9c4f2dabfb4e0e.css +0 -1
- package/web/.next/static/chunks/turbopack-1837909a677d116b.js +0 -3
- package/web/apps/web/.next/server/chunks/[root-of-the-server]__0f75905d._.js +0 -3
- package/web/apps/web/.next/server/chunks/[root-of-the-server]__89e85365._.js +0 -358
- package/web/apps/web/.next/server/chunks/[root-of-the-server]__ae1361d0._.js +0 -3
- package/web/apps/web/.next/server/pages/api/terminal/ws/pages-manifest.json +0 -3
- package/web/apps/web/.next/server/pages/api/terminal/ws.js +0 -5
- package/web/apps/web/.next/server/pages/api/terminal/ws.js.map +0 -5
- package/web/apps/web/.next/server/pages/api/terminal/ws.js.nft.json +0 -1
- package/web/apps/web/.next/server/pages/terminal/build-manifest.json +0 -20
- package/web/apps/web/.next/server/pages/terminal/client-build-manifest.json +0 -5
- package/web/apps/web/.next/server/pages/terminal/next-font-manifest.json +0 -11
- package/web/apps/web/.next/server/pages/terminal/pages-manifest.json +0 -3
- package/web/apps/web/.next/server/pages/terminal/react-loadable-manifest.json +0 -1
- package/web/apps/web/.next/server/pages/terminal.html +0 -1
- package/web/apps/web/.next/server/pages/terminal.js.map +0 -5
- package/web/apps/web/.next/server/pages/terminal.js.nft.json +0 -1
- package/web/node_modules/.bun/@socket.io+component-emitter@3.1.2/node_modules/@socket.io/component-emitter/lib/cjs/index.js +0 -176
- package/web/node_modules/.bun/@socket.io+component-emitter@3.1.2/node_modules/@socket.io/component-emitter/lib/cjs/package.json +0 -4
- package/web/node_modules/.bun/@socket.io+component-emitter@3.1.2/node_modules/@socket.io/component-emitter/package.json +0 -28
- package/web/node_modules/.bun/accepts@1.3.8/node_modules/accepts/index.js +0 -238
- package/web/node_modules/.bun/accepts@1.3.8/node_modules/accepts/package.json +0 -47
- package/web/node_modules/.bun/base64id@2.0.0/node_modules/base64id/lib/base64id.js +0 -103
- package/web/node_modules/.bun/base64id@2.0.0/node_modules/base64id/package.json +0 -13
- package/web/node_modules/.bun/cookie@0.7.2/node_modules/cookie/index.js +0 -335
- package/web/node_modules/.bun/cookie@0.7.2/node_modules/cookie/package.json +0 -44
- package/web/node_modules/.bun/cookie@1.1.1/node_modules/cookie/package.json +0 -47
- package/web/node_modules/.bun/cors@2.8.5/node_modules/cors/lib/index.js +0 -238
- package/web/node_modules/.bun/cors@2.8.5/node_modules/cors/package.json +0 -41
- package/web/node_modules/.bun/debug@4.3.7/node_modules/debug/package.json +0 -60
- package/web/node_modules/.bun/debug@4.3.7/node_modules/debug/src/browser.js +0 -271
- package/web/node_modules/.bun/debug@4.3.7/node_modules/debug/src/common.js +0 -274
- package/web/node_modules/.bun/debug@4.3.7/node_modules/debug/src/index.js +0 -10
- package/web/node_modules/.bun/debug@4.3.7/node_modules/debug/src/node.js +0 -263
- package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/cjs/commons.js +0 -19
- package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/cjs/decodePacket.js +0 -59
- package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/cjs/encodePacket.js +0 -38
- package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/cjs/index.js +0 -164
- package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/cjs/package.json +0 -8
- package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/package.json +0 -46
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/engine.io.js +0 -54
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/parser-v3/index.js +0 -424
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/parser-v3/utf8.js +0 -187
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/server.js +0 -786
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/socket.js +0 -460
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transport.js +0 -117
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports/index.js +0 -23
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports/polling-jsonp.js +0 -41
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports/polling.js +0 -332
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports/websocket.js +0 -94
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports/webtransport.js +0 -63
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports-uws/index.js +0 -8
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports-uws/polling.js +0 -364
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports-uws/websocket.js +0 -73
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/userver.js +0 -279
- package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/package.json +0 -70
- package/web/node_modules/.bun/has-flag@4.0.0/node_modules/has-flag/index.js +0 -8
- package/web/node_modules/.bun/has-flag@4.0.0/node_modules/has-flag/package.json +0 -46
- package/web/node_modules/.bun/mime-db@1.52.0/node_modules/mime-db/db.json +0 -8519
- package/web/node_modules/.bun/mime-db@1.52.0/node_modules/mime-db/index.js +0 -12
- package/web/node_modules/.bun/mime-db@1.52.0/node_modules/mime-db/package.json +0 -60
- package/web/node_modules/.bun/mime-types@2.1.35/node_modules/mime-types/index.js +0 -188
- package/web/node_modules/.bun/mime-types@2.1.35/node_modules/mime-types/package.json +0 -44
- package/web/node_modules/.bun/ms@2.1.3/node_modules/ms/index.js +0 -162
- package/web/node_modules/.bun/ms@2.1.3/node_modules/ms/package.json +0 -38
- package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/index.js +0 -82
- package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/lib/charset.js +0 -169
- package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/lib/encoding.js +0 -184
- package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/lib/language.js +0 -179
- package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/lib/mediaType.js +0 -294
- package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/package.json +0 -42
- package/web/node_modules/.bun/object-assign@4.1.1/node_modules/object-assign/index.js +0 -90
- package/web/node_modules/.bun/object-assign@4.1.1/node_modules/object-assign/package.json +0 -42
- package/web/node_modules/.bun/socket.io-adapter@2.5.5/node_modules/socket.io-adapter/dist/cluster-adapter.js +0 -674
- package/web/node_modules/.bun/socket.io-adapter@2.5.5/node_modules/socket.io-adapter/dist/contrib/yeast.js +0 -55
- package/web/node_modules/.bun/socket.io-adapter@2.5.5/node_modules/socket.io-adapter/dist/in-memory-adapter.js +0 -394
- package/web/node_modules/.bun/socket.io-adapter@2.5.5/node_modules/socket.io-adapter/dist/index.js +0 -10
- package/web/node_modules/.bun/socket.io-adapter@2.5.5/node_modules/socket.io-adapter/package.json +0 -39
- package/web/node_modules/.bun/socket.io-parser@4.2.4/node_modules/socket.io-parser/build/cjs/binary.js +0 -88
- package/web/node_modules/.bun/socket.io-parser@4.2.4/node_modules/socket.io-parser/build/cjs/index.js +0 -321
- package/web/node_modules/.bun/socket.io-parser@4.2.4/node_modules/socket.io-parser/build/cjs/is-binary.js +0 -55
- package/web/node_modules/.bun/socket.io-parser@4.2.4/node_modules/socket.io-parser/build/cjs/package.json +0 -3
- package/web/node_modules/.bun/socket.io-parser@4.2.4/node_modules/socket.io-parser/package.json +0 -58
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/client-dist/socket.io.esm.min.js +0 -7
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/client-dist/socket.io.js +0 -4908
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/client-dist/socket.io.min.js +0 -7
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/client-dist/socket.io.msgpack.min.js +0 -7
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/broadcast-operator.js +0 -436
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/client.js +0 -268
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/index.js +0 -804
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/namespace.js +0 -581
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/parent-namespace.js +0 -88
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/socket-types.js +0 -11
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/socket.js +0 -977
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/typed-events.js +0 -81
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/uws.js +0 -136
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/package.json +0 -85
- package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/wrapper.mjs +0 -3
- package/web/node_modules/.bun/supports-color@7.2.0/node_modules/supports-color/index.js +0 -135
- package/web/node_modules/.bun/supports-color@7.2.0/node_modules/supports-color/package.json +0 -53
- package/web/node_modules/.bun/vary@1.1.2/node_modules/vary/index.js +0 -149
- package/web/node_modules/.bun/vary@1.1.2/node_modules/vary/package.json +0 -43
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/index.js +0 -13
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/buffer-util.js +0 -131
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/constants.js +0 -12
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/event-target.js +0 -292
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/extension.js +0 -203
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/limiter.js +0 -55
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/permessage-deflate.js +0 -514
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/receiver.js +0 -704
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/sender.js +0 -497
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/stream.js +0 -159
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/subprotocol.js +0 -62
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/validation.js +0 -130
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/websocket-server.js +0 -540
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/websocket.js +0 -1338
- package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/package.json +0 -69
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/buffer-util.js +0 -131
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/constants.js +0 -18
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/event-target.js +0 -292
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/extension.js +0 -203
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/limiter.js +0 -55
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/permessage-deflate.js +0 -528
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/receiver.js +0 -706
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/sender.js +0 -602
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/stream.js +0 -161
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/subprotocol.js +0 -62
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/validation.js +0 -152
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/websocket-server.js +0 -550
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/websocket.js +0 -1388
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/package.json +0 -69
- package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/wrapper.mjs +0 -8
- /package/web/.next/static/{A7pW-dtFIbPCSkvE8uenX → Im7EdK1Q3oOmTznohTOr5}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{A7pW-dtFIbPCSkvE8uenX → Im7EdK1Q3oOmTznohTOr5}/_ssgManifest.js +0 -0
package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/broadcast-operator.js
DELETED
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RemoteSocket = exports.BroadcastOperator = void 0;
|
|
4
|
-
const socket_types_1 = require("./socket-types");
|
|
5
|
-
const socket_io_parser_1 = require("socket.io-parser");
|
|
6
|
-
class BroadcastOperator {
|
|
7
|
-
constructor(adapter, rooms = new Set(), exceptRooms = new Set(), flags = {}) {
|
|
8
|
-
this.adapter = adapter;
|
|
9
|
-
this.rooms = rooms;
|
|
10
|
-
this.exceptRooms = exceptRooms;
|
|
11
|
-
this.flags = flags;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Targets a room when emitting.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* // the “foo” event will be broadcast to all connected clients in the “room-101” room
|
|
18
|
-
* io.to("room-101").emit("foo", "bar");
|
|
19
|
-
*
|
|
20
|
-
* // with an array of rooms (a client will be notified at most once)
|
|
21
|
-
* io.to(["room-101", "room-102"]).emit("foo", "bar");
|
|
22
|
-
*
|
|
23
|
-
* // with multiple chained calls
|
|
24
|
-
* io.to("room-101").to("room-102").emit("foo", "bar");
|
|
25
|
-
*
|
|
26
|
-
* @param room - a room, or an array of rooms
|
|
27
|
-
* @return a new {@link BroadcastOperator} instance for chaining
|
|
28
|
-
*/
|
|
29
|
-
to(room) {
|
|
30
|
-
const rooms = new Set(this.rooms);
|
|
31
|
-
if (Array.isArray(room)) {
|
|
32
|
-
room.forEach((r) => rooms.add(r));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
rooms.add(room);
|
|
36
|
-
}
|
|
37
|
-
return new BroadcastOperator(this.adapter, rooms, this.exceptRooms, this.flags);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Targets a room when emitting. Similar to `to()`, but might feel clearer in some cases:
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* // disconnect all clients in the "room-101" room
|
|
44
|
-
* io.in("room-101").disconnectSockets();
|
|
45
|
-
*
|
|
46
|
-
* @param room - a room, or an array of rooms
|
|
47
|
-
* @return a new {@link BroadcastOperator} instance for chaining
|
|
48
|
-
*/
|
|
49
|
-
in(room) {
|
|
50
|
-
return this.to(room);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Excludes a room when emitting.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* // the "foo" event will be broadcast to all connected clients, except the ones that are in the "room-101" room
|
|
57
|
-
* io.except("room-101").emit("foo", "bar");
|
|
58
|
-
*
|
|
59
|
-
* // with an array of rooms
|
|
60
|
-
* io.except(["room-101", "room-102"]).emit("foo", "bar");
|
|
61
|
-
*
|
|
62
|
-
* // with multiple chained calls
|
|
63
|
-
* io.except("room-101").except("room-102").emit("foo", "bar");
|
|
64
|
-
*
|
|
65
|
-
* @param room - a room, or an array of rooms
|
|
66
|
-
* @return a new {@link BroadcastOperator} instance for chaining
|
|
67
|
-
*/
|
|
68
|
-
except(room) {
|
|
69
|
-
const exceptRooms = new Set(this.exceptRooms);
|
|
70
|
-
if (Array.isArray(room)) {
|
|
71
|
-
room.forEach((r) => exceptRooms.add(r));
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
exceptRooms.add(room);
|
|
75
|
-
}
|
|
76
|
-
return new BroadcastOperator(this.adapter, this.rooms, exceptRooms, this.flags);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Sets the compress flag.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* io.compress(false).emit("hello");
|
|
83
|
-
*
|
|
84
|
-
* @param compress - if `true`, compresses the sending data
|
|
85
|
-
* @return a new BroadcastOperator instance
|
|
86
|
-
*/
|
|
87
|
-
compress(compress) {
|
|
88
|
-
const flags = Object.assign({}, this.flags, { compress });
|
|
89
|
-
return new BroadcastOperator(this.adapter, this.rooms, this.exceptRooms, flags);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Sets a modifier for a subsequent event emission that the event data may be lost if the client is not ready to
|
|
93
|
-
* receive messages (because of network slowness or other issues, or because they’re connected through long polling
|
|
94
|
-
* and is in the middle of a request-response cycle).
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* io.volatile.emit("hello"); // the clients may or may not receive it
|
|
98
|
-
*
|
|
99
|
-
* @return a new BroadcastOperator instance
|
|
100
|
-
*/
|
|
101
|
-
get volatile() {
|
|
102
|
-
const flags = Object.assign({}, this.flags, { volatile: true });
|
|
103
|
-
return new BroadcastOperator(this.adapter, this.rooms, this.exceptRooms, flags);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Sets a modifier for a subsequent event emission that the event data will only be broadcast to the current node.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* // the “foo” event will be broadcast to all connected clients on this node
|
|
110
|
-
* io.local.emit("foo", "bar");
|
|
111
|
-
*
|
|
112
|
-
* @return a new {@link BroadcastOperator} instance for chaining
|
|
113
|
-
*/
|
|
114
|
-
get local() {
|
|
115
|
-
const flags = Object.assign({}, this.flags, { local: true });
|
|
116
|
-
return new BroadcastOperator(this.adapter, this.rooms, this.exceptRooms, flags);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Adds a timeout in milliseconds for the next operation
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* io.timeout(1000).emit("some-event", (err, responses) => {
|
|
123
|
-
* if (err) {
|
|
124
|
-
* // some clients did not acknowledge the event in the given delay
|
|
125
|
-
* } else {
|
|
126
|
-
* console.log(responses); // one response per client
|
|
127
|
-
* }
|
|
128
|
-
* });
|
|
129
|
-
*
|
|
130
|
-
* @param timeout
|
|
131
|
-
*/
|
|
132
|
-
timeout(timeout) {
|
|
133
|
-
const flags = Object.assign({}, this.flags, { timeout });
|
|
134
|
-
return new BroadcastOperator(this.adapter, this.rooms, this.exceptRooms, flags);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Emits to all clients.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* // the “foo” event will be broadcast to all connected clients
|
|
141
|
-
* io.emit("foo", "bar");
|
|
142
|
-
*
|
|
143
|
-
* // the “foo” event will be broadcast to all connected clients in the “room-101” room
|
|
144
|
-
* io.to("room-101").emit("foo", "bar");
|
|
145
|
-
*
|
|
146
|
-
* // with an acknowledgement expected from all connected clients
|
|
147
|
-
* io.timeout(1000).emit("some-event", (err, responses) => {
|
|
148
|
-
* if (err) {
|
|
149
|
-
* // some clients did not acknowledge the event in the given delay
|
|
150
|
-
* } else {
|
|
151
|
-
* console.log(responses); // one response per client
|
|
152
|
-
* }
|
|
153
|
-
* });
|
|
154
|
-
*
|
|
155
|
-
* @return Always true
|
|
156
|
-
*/
|
|
157
|
-
emit(ev, ...args) {
|
|
158
|
-
if (socket_types_1.RESERVED_EVENTS.has(ev)) {
|
|
159
|
-
throw new Error(`"${String(ev)}" is a reserved event name`);
|
|
160
|
-
}
|
|
161
|
-
// set up packet object
|
|
162
|
-
const data = [ev, ...args];
|
|
163
|
-
const packet = {
|
|
164
|
-
type: socket_io_parser_1.PacketType.EVENT,
|
|
165
|
-
data: data,
|
|
166
|
-
};
|
|
167
|
-
const withAck = typeof data[data.length - 1] === "function";
|
|
168
|
-
if (!withAck) {
|
|
169
|
-
this.adapter.broadcast(packet, {
|
|
170
|
-
rooms: this.rooms,
|
|
171
|
-
except: this.exceptRooms,
|
|
172
|
-
flags: this.flags,
|
|
173
|
-
});
|
|
174
|
-
return true;
|
|
175
|
-
}
|
|
176
|
-
const ack = data.pop();
|
|
177
|
-
let timedOut = false;
|
|
178
|
-
let responses = [];
|
|
179
|
-
const timer = setTimeout(() => {
|
|
180
|
-
timedOut = true;
|
|
181
|
-
ack.apply(this, [
|
|
182
|
-
new Error("operation has timed out"),
|
|
183
|
-
this.flags.expectSingleResponse ? null : responses,
|
|
184
|
-
]);
|
|
185
|
-
}, this.flags.timeout);
|
|
186
|
-
let expectedServerCount = -1;
|
|
187
|
-
let actualServerCount = 0;
|
|
188
|
-
let expectedClientCount = 0;
|
|
189
|
-
const checkCompleteness = () => {
|
|
190
|
-
if (!timedOut &&
|
|
191
|
-
expectedServerCount === actualServerCount &&
|
|
192
|
-
responses.length === expectedClientCount) {
|
|
193
|
-
clearTimeout(timer);
|
|
194
|
-
ack.apply(this, [
|
|
195
|
-
null,
|
|
196
|
-
this.flags.expectSingleResponse ? responses[0] : responses,
|
|
197
|
-
]);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
this.adapter.broadcastWithAck(packet, {
|
|
201
|
-
rooms: this.rooms,
|
|
202
|
-
except: this.exceptRooms,
|
|
203
|
-
flags: this.flags,
|
|
204
|
-
}, (clientCount) => {
|
|
205
|
-
// each Socket.IO server in the cluster sends the number of clients that were notified
|
|
206
|
-
expectedClientCount += clientCount;
|
|
207
|
-
actualServerCount++;
|
|
208
|
-
checkCompleteness();
|
|
209
|
-
}, (clientResponse) => {
|
|
210
|
-
// each client sends an acknowledgement
|
|
211
|
-
responses.push(clientResponse);
|
|
212
|
-
checkCompleteness();
|
|
213
|
-
});
|
|
214
|
-
this.adapter.serverCount().then((serverCount) => {
|
|
215
|
-
expectedServerCount = serverCount;
|
|
216
|
-
checkCompleteness();
|
|
217
|
-
});
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Emits an event and waits for an acknowledgement from all clients.
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* try {
|
|
225
|
-
* const responses = await io.timeout(1000).emitWithAck("some-event");
|
|
226
|
-
* console.log(responses); // one response per client
|
|
227
|
-
* } catch (e) {
|
|
228
|
-
* // some clients did not acknowledge the event in the given delay
|
|
229
|
-
* }
|
|
230
|
-
*
|
|
231
|
-
* @return a Promise that will be fulfilled when all clients have acknowledged the event
|
|
232
|
-
*/
|
|
233
|
-
emitWithAck(ev, ...args) {
|
|
234
|
-
return new Promise((resolve, reject) => {
|
|
235
|
-
args.push((err, responses) => {
|
|
236
|
-
if (err) {
|
|
237
|
-
err.responses = responses;
|
|
238
|
-
return reject(err);
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
return resolve(responses);
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
this.emit(ev, ...args);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Gets a list of clients.
|
|
249
|
-
*
|
|
250
|
-
* @deprecated this method will be removed in the next major release, please use {@link Server#serverSideEmit} or
|
|
251
|
-
* {@link fetchSockets} instead.
|
|
252
|
-
*/
|
|
253
|
-
allSockets() {
|
|
254
|
-
if (!this.adapter) {
|
|
255
|
-
throw new Error("No adapter for this namespace, are you trying to get the list of clients of a dynamic namespace?");
|
|
256
|
-
}
|
|
257
|
-
return this.adapter.sockets(this.rooms);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Returns the matching socket instances. This method works across a cluster of several Socket.IO servers.
|
|
261
|
-
*
|
|
262
|
-
* Note: this method also works within a cluster of multiple Socket.IO servers, with a compatible {@link Adapter}.
|
|
263
|
-
*
|
|
264
|
-
* @example
|
|
265
|
-
* // return all Socket instances
|
|
266
|
-
* const sockets = await io.fetchSockets();
|
|
267
|
-
*
|
|
268
|
-
* // return all Socket instances in the "room1" room
|
|
269
|
-
* const sockets = await io.in("room1").fetchSockets();
|
|
270
|
-
*
|
|
271
|
-
* for (const socket of sockets) {
|
|
272
|
-
* console.log(socket.id);
|
|
273
|
-
* console.log(socket.handshake);
|
|
274
|
-
* console.log(socket.rooms);
|
|
275
|
-
* console.log(socket.data);
|
|
276
|
-
*
|
|
277
|
-
* socket.emit("hello");
|
|
278
|
-
* socket.join("room1");
|
|
279
|
-
* socket.leave("room2");
|
|
280
|
-
* socket.disconnect();
|
|
281
|
-
* }
|
|
282
|
-
*/
|
|
283
|
-
fetchSockets() {
|
|
284
|
-
return this.adapter
|
|
285
|
-
.fetchSockets({
|
|
286
|
-
rooms: this.rooms,
|
|
287
|
-
except: this.exceptRooms,
|
|
288
|
-
flags: this.flags,
|
|
289
|
-
})
|
|
290
|
-
.then((sockets) => {
|
|
291
|
-
return sockets.map((socket) => {
|
|
292
|
-
if (socket.server) {
|
|
293
|
-
return socket; // local instance
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
return new RemoteSocket(this.adapter, socket);
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Makes the matching socket instances join the specified rooms.
|
|
303
|
-
*
|
|
304
|
-
* Note: this method also works within a cluster of multiple Socket.IO servers, with a compatible {@link Adapter}.
|
|
305
|
-
*
|
|
306
|
-
* @example
|
|
307
|
-
*
|
|
308
|
-
* // make all socket instances join the "room1" room
|
|
309
|
-
* io.socketsJoin("room1");
|
|
310
|
-
*
|
|
311
|
-
* // make all socket instances in the "room1" room join the "room2" and "room3" rooms
|
|
312
|
-
* io.in("room1").socketsJoin(["room2", "room3"]);
|
|
313
|
-
*
|
|
314
|
-
* @param room - a room, or an array of rooms
|
|
315
|
-
*/
|
|
316
|
-
socketsJoin(room) {
|
|
317
|
-
this.adapter.addSockets({
|
|
318
|
-
rooms: this.rooms,
|
|
319
|
-
except: this.exceptRooms,
|
|
320
|
-
flags: this.flags,
|
|
321
|
-
}, Array.isArray(room) ? room : [room]);
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Makes the matching socket instances leave the specified rooms.
|
|
325
|
-
*
|
|
326
|
-
* Note: this method also works within a cluster of multiple Socket.IO servers, with a compatible {@link Adapter}.
|
|
327
|
-
*
|
|
328
|
-
* @example
|
|
329
|
-
* // make all socket instances leave the "room1" room
|
|
330
|
-
* io.socketsLeave("room1");
|
|
331
|
-
*
|
|
332
|
-
* // make all socket instances in the "room1" room leave the "room2" and "room3" rooms
|
|
333
|
-
* io.in("room1").socketsLeave(["room2", "room3"]);
|
|
334
|
-
*
|
|
335
|
-
* @param room - a room, or an array of rooms
|
|
336
|
-
*/
|
|
337
|
-
socketsLeave(room) {
|
|
338
|
-
this.adapter.delSockets({
|
|
339
|
-
rooms: this.rooms,
|
|
340
|
-
except: this.exceptRooms,
|
|
341
|
-
flags: this.flags,
|
|
342
|
-
}, Array.isArray(room) ? room : [room]);
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Makes the matching socket instances disconnect.
|
|
346
|
-
*
|
|
347
|
-
* Note: this method also works within a cluster of multiple Socket.IO servers, with a compatible {@link Adapter}.
|
|
348
|
-
*
|
|
349
|
-
* @example
|
|
350
|
-
* // make all socket instances disconnect (the connections might be kept alive for other namespaces)
|
|
351
|
-
* io.disconnectSockets();
|
|
352
|
-
*
|
|
353
|
-
* // make all socket instances in the "room1" room disconnect and close the underlying connections
|
|
354
|
-
* io.in("room1").disconnectSockets(true);
|
|
355
|
-
*
|
|
356
|
-
* @param close - whether to close the underlying connection
|
|
357
|
-
*/
|
|
358
|
-
disconnectSockets(close = false) {
|
|
359
|
-
this.adapter.disconnectSockets({
|
|
360
|
-
rooms: this.rooms,
|
|
361
|
-
except: this.exceptRooms,
|
|
362
|
-
flags: this.flags,
|
|
363
|
-
}, close);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
exports.BroadcastOperator = BroadcastOperator;
|
|
367
|
-
/**
|
|
368
|
-
* Expose of subset of the attributes and methods of the Socket class
|
|
369
|
-
*/
|
|
370
|
-
class RemoteSocket {
|
|
371
|
-
constructor(adapter, details) {
|
|
372
|
-
this.id = details.id;
|
|
373
|
-
this.handshake = details.handshake;
|
|
374
|
-
this.rooms = new Set(details.rooms);
|
|
375
|
-
this.data = details.data;
|
|
376
|
-
this.operator = new BroadcastOperator(adapter, new Set([this.id]), new Set(), {
|
|
377
|
-
expectSingleResponse: true, // so that remoteSocket.emit() with acknowledgement behaves like socket.emit()
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Adds a timeout in milliseconds for the next operation.
|
|
382
|
-
*
|
|
383
|
-
* @example
|
|
384
|
-
* const sockets = await io.fetchSockets();
|
|
385
|
-
*
|
|
386
|
-
* for (const socket of sockets) {
|
|
387
|
-
* if (someCondition) {
|
|
388
|
-
* socket.timeout(1000).emit("some-event", (err) => {
|
|
389
|
-
* if (err) {
|
|
390
|
-
* // the client did not acknowledge the event in the given delay
|
|
391
|
-
* }
|
|
392
|
-
* });
|
|
393
|
-
* }
|
|
394
|
-
* }
|
|
395
|
-
*
|
|
396
|
-
* // note: if possible, using a room instead of looping over all sockets is preferable
|
|
397
|
-
* io.timeout(1000).to(someConditionRoom).emit("some-event", (err, responses) => {
|
|
398
|
-
* // ...
|
|
399
|
-
* });
|
|
400
|
-
*
|
|
401
|
-
* @param timeout
|
|
402
|
-
*/
|
|
403
|
-
timeout(timeout) {
|
|
404
|
-
return this.operator.timeout(timeout);
|
|
405
|
-
}
|
|
406
|
-
emit(ev, ...args) {
|
|
407
|
-
return this.operator.emit(ev, ...args);
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Joins a room.
|
|
411
|
-
*
|
|
412
|
-
* @param {String|Array} room - room or array of rooms
|
|
413
|
-
*/
|
|
414
|
-
join(room) {
|
|
415
|
-
return this.operator.socketsJoin(room);
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Leaves a room.
|
|
419
|
-
*
|
|
420
|
-
* @param {String} room
|
|
421
|
-
*/
|
|
422
|
-
leave(room) {
|
|
423
|
-
return this.operator.socketsLeave(room);
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Disconnects this client.
|
|
427
|
-
*
|
|
428
|
-
* @param {Boolean} close - if `true`, closes the underlying connection
|
|
429
|
-
* @return {Socket} self
|
|
430
|
-
*/
|
|
431
|
-
disconnect(close = false) {
|
|
432
|
-
this.operator.disconnectSockets(close);
|
|
433
|
-
return this;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
exports.RemoteSocket = RemoteSocket;
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Client = void 0;
|
|
4
|
-
const socket_io_parser_1 = require("socket.io-parser");
|
|
5
|
-
const debugModule = require("debug");
|
|
6
|
-
const url = require("url");
|
|
7
|
-
const debug = debugModule("socket.io:client");
|
|
8
|
-
class Client {
|
|
9
|
-
/**
|
|
10
|
-
* Client constructor.
|
|
11
|
-
*
|
|
12
|
-
* @param server instance
|
|
13
|
-
* @param conn
|
|
14
|
-
* @package
|
|
15
|
-
*/
|
|
16
|
-
constructor(server, conn) {
|
|
17
|
-
this.sockets = new Map();
|
|
18
|
-
this.nsps = new Map();
|
|
19
|
-
this.server = server;
|
|
20
|
-
this.conn = conn;
|
|
21
|
-
this.encoder = server.encoder;
|
|
22
|
-
this.decoder = new server._parser.Decoder();
|
|
23
|
-
this.id = conn.id;
|
|
24
|
-
this.setup();
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @return the reference to the request that originated the Engine.IO connection
|
|
28
|
-
*
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
get request() {
|
|
32
|
-
return this.conn.request;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Sets up event listeners.
|
|
36
|
-
*
|
|
37
|
-
* @private
|
|
38
|
-
*/
|
|
39
|
-
setup() {
|
|
40
|
-
this.onclose = this.onclose.bind(this);
|
|
41
|
-
this.ondata = this.ondata.bind(this);
|
|
42
|
-
this.onerror = this.onerror.bind(this);
|
|
43
|
-
this.ondecoded = this.ondecoded.bind(this);
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
this.decoder.on("decoded", this.ondecoded);
|
|
46
|
-
this.conn.on("data", this.ondata);
|
|
47
|
-
this.conn.on("error", this.onerror);
|
|
48
|
-
this.conn.on("close", this.onclose);
|
|
49
|
-
this.connectTimeout = setTimeout(() => {
|
|
50
|
-
if (this.nsps.size === 0) {
|
|
51
|
-
debug("no namespace joined yet, close the client");
|
|
52
|
-
this.close();
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
debug("the client has already joined a namespace, nothing to do");
|
|
56
|
-
}
|
|
57
|
-
}, this.server._connectTimeout);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Connects a client to a namespace.
|
|
61
|
-
*
|
|
62
|
-
* @param {String} name - the namespace
|
|
63
|
-
* @param {Object} auth - the auth parameters
|
|
64
|
-
* @private
|
|
65
|
-
*/
|
|
66
|
-
connect(name, auth = {}) {
|
|
67
|
-
if (this.server._nsps.has(name)) {
|
|
68
|
-
debug("connecting to namespace %s", name);
|
|
69
|
-
return this.doConnect(name, auth);
|
|
70
|
-
}
|
|
71
|
-
this.server._checkNamespace(name, auth, (dynamicNspName) => {
|
|
72
|
-
if (dynamicNspName) {
|
|
73
|
-
this.doConnect(name, auth);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
debug("creation of namespace %s was denied", name);
|
|
77
|
-
this._packet({
|
|
78
|
-
type: socket_io_parser_1.PacketType.CONNECT_ERROR,
|
|
79
|
-
nsp: name,
|
|
80
|
-
data: {
|
|
81
|
-
message: "Invalid namespace",
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Connects a client to a namespace.
|
|
89
|
-
*
|
|
90
|
-
* @param name - the namespace
|
|
91
|
-
* @param {Object} auth - the auth parameters
|
|
92
|
-
*
|
|
93
|
-
* @private
|
|
94
|
-
*/
|
|
95
|
-
doConnect(name, auth) {
|
|
96
|
-
const nsp = this.server.of(name);
|
|
97
|
-
nsp._add(this, auth, (socket) => {
|
|
98
|
-
this.sockets.set(socket.id, socket);
|
|
99
|
-
this.nsps.set(nsp.name, socket);
|
|
100
|
-
if (this.connectTimeout) {
|
|
101
|
-
clearTimeout(this.connectTimeout);
|
|
102
|
-
this.connectTimeout = undefined;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Disconnects from all namespaces and closes transport.
|
|
108
|
-
*
|
|
109
|
-
* @private
|
|
110
|
-
*/
|
|
111
|
-
_disconnect() {
|
|
112
|
-
for (const socket of this.sockets.values()) {
|
|
113
|
-
socket.disconnect();
|
|
114
|
-
}
|
|
115
|
-
this.sockets.clear();
|
|
116
|
-
this.close();
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Removes a socket. Called by each `Socket`.
|
|
120
|
-
*
|
|
121
|
-
* @private
|
|
122
|
-
*/
|
|
123
|
-
_remove(socket) {
|
|
124
|
-
if (this.sockets.has(socket.id)) {
|
|
125
|
-
const nsp = this.sockets.get(socket.id).nsp.name;
|
|
126
|
-
this.sockets.delete(socket.id);
|
|
127
|
-
this.nsps.delete(nsp);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
debug("ignoring remove for %s", socket.id);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Closes the underlying connection.
|
|
135
|
-
*
|
|
136
|
-
* @private
|
|
137
|
-
*/
|
|
138
|
-
close() {
|
|
139
|
-
if ("open" === this.conn.readyState) {
|
|
140
|
-
debug("forcing transport close");
|
|
141
|
-
this.conn.close();
|
|
142
|
-
this.onclose("forced server close");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Writes a packet to the transport.
|
|
147
|
-
*
|
|
148
|
-
* @param {Object} packet object
|
|
149
|
-
* @param {Object} opts
|
|
150
|
-
* @private
|
|
151
|
-
*/
|
|
152
|
-
_packet(packet, opts = {}) {
|
|
153
|
-
if (this.conn.readyState !== "open") {
|
|
154
|
-
debug("ignoring packet write %j", packet);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const encodedPackets = opts.preEncoded
|
|
158
|
-
? packet // previous versions of the adapter incorrectly used socket.packet() instead of writeToEngine()
|
|
159
|
-
: this.encoder.encode(packet);
|
|
160
|
-
this.writeToEngine(encodedPackets, opts);
|
|
161
|
-
}
|
|
162
|
-
writeToEngine(encodedPackets, opts) {
|
|
163
|
-
if (opts.volatile && !this.conn.transport.writable) {
|
|
164
|
-
debug("volatile packet is discarded since the transport is not currently writable");
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
const packets = Array.isArray(encodedPackets)
|
|
168
|
-
? encodedPackets
|
|
169
|
-
: [encodedPackets];
|
|
170
|
-
for (const encodedPacket of packets) {
|
|
171
|
-
this.conn.write(encodedPacket, opts);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Called with incoming transport data.
|
|
176
|
-
*
|
|
177
|
-
* @private
|
|
178
|
-
*/
|
|
179
|
-
ondata(data) {
|
|
180
|
-
// try/catch is needed for protocol violations (GH-1880)
|
|
181
|
-
try {
|
|
182
|
-
this.decoder.add(data);
|
|
183
|
-
}
|
|
184
|
-
catch (e) {
|
|
185
|
-
debug("invalid packet format");
|
|
186
|
-
this.onerror(e);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Called when parser fully decodes a packet.
|
|
191
|
-
*
|
|
192
|
-
* @private
|
|
193
|
-
*/
|
|
194
|
-
ondecoded(packet) {
|
|
195
|
-
let namespace;
|
|
196
|
-
let authPayload;
|
|
197
|
-
if (this.conn.protocol === 3) {
|
|
198
|
-
const parsed = url.parse(packet.nsp, true);
|
|
199
|
-
namespace = parsed.pathname;
|
|
200
|
-
authPayload = parsed.query;
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
namespace = packet.nsp;
|
|
204
|
-
authPayload = packet.data;
|
|
205
|
-
}
|
|
206
|
-
const socket = this.nsps.get(namespace);
|
|
207
|
-
if (!socket && packet.type === socket_io_parser_1.PacketType.CONNECT) {
|
|
208
|
-
this.connect(namespace, authPayload);
|
|
209
|
-
}
|
|
210
|
-
else if (socket &&
|
|
211
|
-
packet.type !== socket_io_parser_1.PacketType.CONNECT &&
|
|
212
|
-
packet.type !== socket_io_parser_1.PacketType.CONNECT_ERROR) {
|
|
213
|
-
process.nextTick(function () {
|
|
214
|
-
socket._onpacket(packet);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
debug("invalid state (packet type: %s)", packet.type);
|
|
219
|
-
this.close();
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Handles an error.
|
|
224
|
-
*
|
|
225
|
-
* @param {Object} err object
|
|
226
|
-
* @private
|
|
227
|
-
*/
|
|
228
|
-
onerror(err) {
|
|
229
|
-
for (const socket of this.sockets.values()) {
|
|
230
|
-
socket._onerror(err);
|
|
231
|
-
}
|
|
232
|
-
this.conn.close();
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Called upon transport close.
|
|
236
|
-
*
|
|
237
|
-
* @param reason
|
|
238
|
-
* @param description
|
|
239
|
-
* @private
|
|
240
|
-
*/
|
|
241
|
-
onclose(reason, description) {
|
|
242
|
-
debug("client close with reason %s", reason);
|
|
243
|
-
// ignore a potential subsequent `close` event
|
|
244
|
-
this.destroy();
|
|
245
|
-
// `nsps` and `sockets` are cleaned up seamlessly
|
|
246
|
-
for (const socket of this.sockets.values()) {
|
|
247
|
-
socket._onclose(reason, description);
|
|
248
|
-
}
|
|
249
|
-
this.sockets.clear();
|
|
250
|
-
this.decoder.destroy(); // clean up decoder
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Cleans up event listeners.
|
|
254
|
-
* @private
|
|
255
|
-
*/
|
|
256
|
-
destroy() {
|
|
257
|
-
this.conn.removeListener("data", this.ondata);
|
|
258
|
-
this.conn.removeListener("error", this.onerror);
|
|
259
|
-
this.conn.removeListener("close", this.onclose);
|
|
260
|
-
// @ts-ignore
|
|
261
|
-
this.decoder.removeListener("decoded", this.ondecoded);
|
|
262
|
-
if (this.connectTimeout) {
|
|
263
|
-
clearTimeout(this.connectTimeout);
|
|
264
|
-
this.connectTimeout = undefined;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
exports.Client = Client;
|