mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-07 22:23:57 -05:00
Merge remote-tracking branch 'socket.io-cluster-adapter/monorepo'
This commit is contained in:
547
package-lock.json
generated
547
package-lock.json
generated
@@ -12,6 +12,7 @@
|
||||
"packages/socket.io-cluster-engine",
|
||||
"packages/engine.io-client",
|
||||
"packages/socket.io-adapter",
|
||||
"packages/socket.io-cluster-adapter",
|
||||
"packages/socket.io-parser",
|
||||
"packages/socket.io-client",
|
||||
"packages/socket.io",
|
||||
@@ -72,6 +73,7 @@
|
||||
"ts-loader": "^9.5.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsd": "^0.31.1",
|
||||
"tsx": "~4.20.6",
|
||||
"typescript": "^5.5.3",
|
||||
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.48.0",
|
||||
"wdio-geckodriver-service": "^5.0.2"
|
||||
@@ -1829,6 +1831,448 @@
|
||||
"fd-slicer2": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.11.tgz",
|
||||
"integrity": "sha512-Xt1dOL13m8u0WE8iplx9Ibbm+hFAO0GsU2P34UNoDGvZYkY8ifSiy6Zuc1lYxfG7svWE2fzqCUmFp5HCn51gJg==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"aix"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.11.tgz",
|
||||
"integrity": "sha512-uoa7dU+Dt3HYsethkJ1k6Z9YdcHjTrSb5NUy66ZfZaSV8hEYGD5ZHbEMXnqLFlbBflLsl89Zke7CAdDJ4JI+Gg==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.11.tgz",
|
||||
"integrity": "sha512-9slpyFBc4FPPz48+f6jyiXOx/Y4v34TUeDDXJpZqAWQn/08lKGeD8aDp9TMn9jDz2CiEuHwfhRmGBvpnd/PWIQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-x64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.11.tgz",
|
||||
"integrity": "sha512-Sgiab4xBjPU1QoPEIqS3Xx+R2lezu0LKIEcYe6pftr56PqPygbB7+szVnzoShbx64MUupqoE0KyRlN7gezbl8g==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-arm64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.11.tgz",
|
||||
"integrity": "sha512-VekY0PBCukppoQrycFxUqkCojnTQhdec0vevUL/EDOCnXd9LKWqD/bHwMPzigIJXPhC59Vd1WFIL57SKs2mg4w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-x64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.11.tgz",
|
||||
"integrity": "sha512-+hfp3yfBalNEpTGp9loYgbknjR695HkqtY3d3/JjSRUyPg/xd6q+mQqIb5qdywnDxRZykIHs3axEqU6l1+oWEQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-arm64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.11.tgz",
|
||||
"integrity": "sha512-CmKjrnayyTJF2eVuO//uSjl/K3KsMIeYeyN7FyDBjsR3lnSJHaXlVoAK8DZa7lXWChbuOk7NjAc7ygAwrnPBhA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-x64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.11.tgz",
|
||||
"integrity": "sha512-Dyq+5oscTJvMaYPvW3x3FLpi2+gSZTCE/1ffdwuM6G1ARang/mb3jvjxs0mw6n3Lsw84ocfo9CrNMqc5lTfGOw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.11.tgz",
|
||||
"integrity": "sha512-TBMv6B4kCfrGJ8cUPo7vd6NECZH/8hPpBHHlYI3qzoYFvWu2AdTvZNuU/7hsbKWqu/COU7NIK12dHAAqBLLXgw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.11.tgz",
|
||||
"integrity": "sha512-Qr8AzcplUhGvdyUF08A1kHU3Vr2O88xxP0Tm8GcdVOUm25XYcMPp2YqSVHbLuXzYQMf9Bh/iKx7YPqECs6ffLA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ia32": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.11.tgz",
|
||||
"integrity": "sha512-TmnJg8BMGPehs5JKrCLqyWTVAvielc615jbkOirATQvWWB1NMXY77oLMzsUjRLa0+ngecEmDGqt5jiDC6bfvOw==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-loong64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.11.tgz",
|
||||
"integrity": "sha512-DIGXL2+gvDaXlaq8xruNXUJdT5tF+SBbJQKbWy/0J7OhU8gOHOzKmGIlfTTl6nHaCOoipxQbuJi7O++ldrxgMw==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-mips64el": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.11.tgz",
|
||||
"integrity": "sha512-Osx1nALUJu4pU43o9OyjSCXokFkFbyzjXb6VhGIJZQ5JZi8ylCQ9/LFagolPsHtgw6himDSyb5ETSfmp4rpiKQ==",
|
||||
"cpu": [
|
||||
"mips64el"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ppc64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.11.tgz",
|
||||
"integrity": "sha512-nbLFgsQQEsBa8XSgSTSlrnBSrpoWh7ioFDUmwo158gIm5NNP+17IYmNWzaIzWmgCxq56vfr34xGkOcZ7jX6CPw==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-riscv64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.11.tgz",
|
||||
"integrity": "sha512-HfyAmqZi9uBAbgKYP1yGuI7tSREXwIb438q0nqvlpxAOs3XnZ8RsisRfmVsgV486NdjD7Mw2UrFSw51lzUk1ww==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-s390x": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.11.tgz",
|
||||
"integrity": "sha512-HjLqVgSSYnVXRisyfmzsH6mXqyvj0SA7pG5g+9W7ESgwA70AXYNpfKBqh1KbTxmQVaYxpzA/SvlB9oclGPbApw==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-x64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.11.tgz",
|
||||
"integrity": "sha512-HSFAT4+WYjIhrHxKBwGmOOSpphjYkcswF449j6EjsjbinTZbp8PJtjsVK1XFJStdzXdy/jaddAep2FGY+wyFAQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-arm64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.11.tgz",
|
||||
"integrity": "sha512-hr9Oxj1Fa4r04dNpWr3P8QKVVsjQhqrMSUzZzf+LZcYjZNqhA3IAfPQdEh1FLVUJSiu6sgAwp3OmwBfbFgG2Xg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-x64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.11.tgz",
|
||||
"integrity": "sha512-u7tKA+qbzBydyj0vgpu+5h5AeudxOAGncb8N6C9Kh1N4n7wU1Xw1JDApsRjpShRpXRQlJLb9wY28ELpwdPcZ7A==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-arm64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.11.tgz",
|
||||
"integrity": "sha512-Qq6YHhayieor3DxFOoYM1q0q1uMFYb7cSpLD2qzDSvK1NAvqFi8Xgivv0cFC6J+hWVw2teCYltyy9/m/14ryHg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-x64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.11.tgz",
|
||||
"integrity": "sha512-CN+7c++kkbrckTOz5hrehxWN7uIhFFlmS/hqziSFVWpAzpWrQoAG4chH+nN3Be+Kzv/uuo7zhX716x3Sn2Jduw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openharmony-arm64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.11.tgz",
|
||||
"integrity": "sha512-rOREuNIQgaiR+9QuNkbkxubbp8MSO9rONmwP5nKncnWJ9v5jQ4JxFnLu4zDSRPf3x4u+2VN4pM4RdyIzDty/wQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openharmony"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/sunos-x64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.11.tgz",
|
||||
"integrity": "sha512-nq2xdYaWxyg9DcIyXkZhcYulC6pQ2FuCgem3LI92IwMgIZ69KHeY8T4Y88pcwoLIjbed8n36CyKoYRDygNSGhA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"sunos"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-arm64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.11.tgz",
|
||||
"integrity": "sha512-3XxECOWJq1qMZ3MN8srCJ/QfoLpL+VaxD/WfNRm1O3B4+AZ/BnLVgFbUV3eiRYDMXetciH16dwPbbHqwe1uU0Q==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-ia32": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.11.tgz",
|
||||
"integrity": "sha512-3ukss6gb9XZ8TlRyJlgLn17ecsK4NSQTmdIXRASVsiS2sQ6zPPZklNJT5GR5tE/MUarymmy8kCEf5xPCNCqVOA==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-x64": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.11.tgz",
|
||||
"integrity": "sha512-D7Hpz6A2L4hzsRpPaCYkQnGOotdUpDzSGRIv9I+1ITdHROSFUWW95ZPZWQmGka1Fg7W3zFJowyn9WGwMJ0+KPA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@fails-components/webtransport": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@fails-components/webtransport/-/webtransport-1.1.4.tgz",
|
||||
@@ -2699,6 +3143,10 @@
|
||||
"@sinonjs/commons": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@socket.io/cluster-adapter": {
|
||||
"resolved": "packages/socket.io-cluster-adapter",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@socket.io/cluster-engine": {
|
||||
"resolved": "packages/socket.io-cluster-engine",
|
||||
"link": true
|
||||
@@ -7311,6 +7759,48 @@
|
||||
"integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.25.11",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.11.tgz",
|
||||
"integrity": "sha512-KohQwyzrKTQmhXDW1PjCv3Tyspn9n5GcY2RTDqeORIdIJY8yKIF7sTSopFmn/wpMPW4rdPXI0UE5LJLuq3bx0Q==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.25.11",
|
||||
"@esbuild/android-arm": "0.25.11",
|
||||
"@esbuild/android-arm64": "0.25.11",
|
||||
"@esbuild/android-x64": "0.25.11",
|
||||
"@esbuild/darwin-arm64": "0.25.11",
|
||||
"@esbuild/darwin-x64": "0.25.11",
|
||||
"@esbuild/freebsd-arm64": "0.25.11",
|
||||
"@esbuild/freebsd-x64": "0.25.11",
|
||||
"@esbuild/linux-arm": "0.25.11",
|
||||
"@esbuild/linux-arm64": "0.25.11",
|
||||
"@esbuild/linux-ia32": "0.25.11",
|
||||
"@esbuild/linux-loong64": "0.25.11",
|
||||
"@esbuild/linux-mips64el": "0.25.11",
|
||||
"@esbuild/linux-ppc64": "0.25.11",
|
||||
"@esbuild/linux-riscv64": "0.25.11",
|
||||
"@esbuild/linux-s390x": "0.25.11",
|
||||
"@esbuild/linux-x64": "0.25.11",
|
||||
"@esbuild/netbsd-arm64": "0.25.11",
|
||||
"@esbuild/netbsd-x64": "0.25.11",
|
||||
"@esbuild/openbsd-arm64": "0.25.11",
|
||||
"@esbuild/openbsd-x64": "0.25.11",
|
||||
"@esbuild/openharmony-arm64": "0.25.11",
|
||||
"@esbuild/sunos-x64": "0.25.11",
|
||||
"@esbuild/win32-arm64": "0.25.11",
|
||||
"@esbuild/win32-ia32": "0.25.11",
|
||||
"@esbuild/win32-x64": "0.25.11"
|
||||
}
|
||||
},
|
||||
"node_modules/escalade": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
||||
@@ -8482,6 +8972,19 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/get-tsconfig": {
|
||||
"version": "4.12.0",
|
||||
"resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.12.0.tgz",
|
||||
"integrity": "sha512-LScr2aNr2FbjAjZh2C6X6BxRx1/x+aTDExct/xyq2XKbYOiG5c0aK7pMsSuyc0brz3ibr/lbQiHD9jzt4lccJw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"resolve-pkg-maps": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/get-uri": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.3.tgz",
|
||||
@@ -12515,6 +13018,16 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/resolve-pkg-maps": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz",
|
||||
"integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/responselike": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz",
|
||||
@@ -14278,6 +14791,26 @@
|
||||
"integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/tsx": {
|
||||
"version": "4.20.6",
|
||||
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.6.tgz",
|
||||
"integrity": "sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "~0.25.0",
|
||||
"get-tsconfig": "^4.7.5"
|
||||
},
|
||||
"bin": {
|
||||
"tsx": "dist/cli.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/tunnel": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||
@@ -15580,6 +16113,20 @@
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"packages/socket.io-cluster-adapter": {
|
||||
"name": "@socket.io/cluster-adapter",
|
||||
"version": "0.2.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "~4.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"socket.io-adapter": "~2.5.5"
|
||||
}
|
||||
},
|
||||
"packages/socket.io-cluster-engine": {
|
||||
"name": "@socket.io/cluster-engine",
|
||||
"version": "0.1.0",
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"packages/socket.io-cluster-engine",
|
||||
"packages/engine.io-client",
|
||||
"packages/socket.io-adapter",
|
||||
"packages/socket.io-cluster-adapter",
|
||||
"packages/socket.io-parser",
|
||||
"packages/socket.io-client",
|
||||
"packages/socket.io",
|
||||
@@ -73,6 +74,7 @@
|
||||
"ts-loader": "^9.5.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsd": "^0.31.1",
|
||||
"tsx": "~4.20.6",
|
||||
"typescript": "^5.5.3",
|
||||
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.48.0",
|
||||
"wdio-geckodriver-service": "^5.0.2"
|
||||
|
||||
51
packages/socket.io-cluster-adapter/CHANGELOG.md
Normal file
51
packages/socket.io-cluster-adapter/CHANGELOG.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# History
|
||||
|
||||
- [0.2.2](#022-2023-03-24) (Mar 2023)
|
||||
- [0.2.1](#021-2022-10-13) (Oct 2022)
|
||||
- [0.2.0](#020-2022-04-28) (Apr 2022)
|
||||
- [0.1.0](#010-2021-06-22) (Jun 2021)
|
||||
|
||||
|
||||
|
||||
# Release notes
|
||||
|
||||
## [0.2.2](https://github.com/socketio/socket.io-cluster-adapter/compare/0.2.1...0.2.2) (2023-03-24)
|
||||
|
||||
The `socket.io-adapter` package was added to the list of `peerDependencies`, in order to fix sync issues with the version imported by the socket.io package (see [15fd56e](https://github.com/socketio/socket.io-cluster-adapter/commit/15fd56e78d52aa65c5fbf412dec57ab4bdaee7cc)).
|
||||
|
||||
Support for connection state recovery (see [here](https://github.com/socketio/socket.io/releases/4.6.0)) will be added in the next release.
|
||||
|
||||
|
||||
|
||||
## [0.2.1](https://github.com/socketio/socket.io-cluster-adapter/compare/0.2.0...0.2.1) (2022-10-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* properly handle ERR_IPC_CHANNEL_CLOSED errors ([#6](https://github.com/socketio/socket.io-cluster-adapter/issues/6)) ([be0a0e3](https://github.com/socketio/socket.io-cluster-adapter/commit/be0a0e3217bd7100d569e5624194612bcc8b96ff))
|
||||
|
||||
|
||||
|
||||
## [0.2.0](https://github.com/socketio/socket.io-cluster-adapter/compare/0.1.0...0.2.0) (2022-04-28)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* broadcast and expect multiple acks ([055b784](https://github.com/socketio/socket.io-cluster-adapter/commit/055b7840d8cf88173d8299041ef3fafa9791c97a))
|
||||
|
||||
This feature was added in `socket.io@4.5.0`:
|
||||
|
||||
```js
|
||||
io.timeout(1000).emit("some-event", (err, responses) => {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
Thanks to this change, it will now work within a Node.js cluster.
|
||||
|
||||
|
||||
|
||||
## 0.1.0 (2021-06-22)
|
||||
|
||||
Initial commit
|
||||
|
||||
7
packages/socket.io-cluster-adapter/LICENSE
Normal file
7
packages/socket.io-cluster-adapter/LICENSE
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2021 Damien Arrachequesne (@darrachequesne)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
100
packages/socket.io-cluster-adapter/README.md
Normal file
100
packages/socket.io-cluster-adapter/README.md
Normal file
@@ -0,0 +1,100 @@
|
||||
# Socket.IO cluster adapter
|
||||
|
||||
The `@socket.io/cluster-adapter` package allows broadcasting packets between multiple Socket.IO servers.
|
||||
|
||||

|
||||
|
||||
It can be used in conjunction with [`@socket.io/sticky`](https://github.com/socketio/socket.io-sticky) to broadcast packets between the workers of the same Node.js [cluster](https://nodejs.org/api/cluster.html).
|
||||
|
||||
Supported features:
|
||||
|
||||
- [broadcasting](https://socket.io/docs/v4/broadcasting-events/)
|
||||
- [utility methods](https://socket.io/docs/v4/server-instance/#Utility-methods)
|
||||
- [`socketsJoin`](https://socket.io/docs/v4/server-instance/#socketsJoin)
|
||||
- [`socketsLeave`](https://socket.io/docs/v4/server-instance/#socketsLeave)
|
||||
- [`disconnectSockets`](https://socket.io/docs/v4/server-instance/#disconnectSockets)
|
||||
- [`fetchSockets`](https://socket.io/docs/v4/server-instance/#fetchSockets)
|
||||
- [`serverSideEmit`](https://socket.io/docs/v4/server-instance/#serverSideEmit)
|
||||
|
||||
Related packages:
|
||||
|
||||
- Postgres adapter: https://github.com/socketio/socket.io-postgres-adapter/
|
||||
- Redis adapter: https://github.com/socketio/socket.io-redis-adapter/
|
||||
- MongoDB adapter: https://github.com/socketio/socket.io-mongo-adapter/
|
||||
|
||||
**Table of contents**
|
||||
|
||||
- [Installation](#installation)
|
||||
- [Usage](#usage)
|
||||
- [License](#license)
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install @socket.io/cluster-adapter
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const cluster = require("cluster");
|
||||
const http = require("http");
|
||||
const { Server } = require("socket.io");
|
||||
const numCPUs = require("os").cpus().length;
|
||||
const { setupMaster, setupWorker } = require("@socket.io/sticky");
|
||||
const { createAdapter, setupPrimary } = require("@socket.io/cluster-adapter");
|
||||
|
||||
if (cluster.isMaster) {
|
||||
console.log(`Master ${process.pid} is running`);
|
||||
|
||||
const httpServer = http.createServer();
|
||||
|
||||
// setup sticky sessions
|
||||
setupMaster(httpServer, {
|
||||
loadBalancingMethod: "least-connection",
|
||||
});
|
||||
|
||||
// setup connections between the workers
|
||||
setupPrimary();
|
||||
|
||||
// needed for packets containing buffers (you can ignore it if you only send plaintext objects)
|
||||
// Node.js < 16.0.0
|
||||
cluster.setupMaster({
|
||||
serialization: "advanced",
|
||||
});
|
||||
// Node.js > 16.0.0
|
||||
// cluster.setupPrimary({
|
||||
// serialization: "advanced",
|
||||
// });
|
||||
|
||||
httpServer.listen(3000);
|
||||
|
||||
for (let i = 0; i < numCPUs; i++) {
|
||||
cluster.fork();
|
||||
}
|
||||
|
||||
cluster.on("exit", (worker) => {
|
||||
console.log(`Worker ${worker.process.pid} died`);
|
||||
cluster.fork();
|
||||
});
|
||||
} else {
|
||||
console.log(`Worker ${process.pid} started`);
|
||||
|
||||
const httpServer = http.createServer();
|
||||
const io = new Server(httpServer);
|
||||
|
||||
// use the cluster adapter
|
||||
io.adapter(createAdapter());
|
||||
|
||||
// setup connection with the primary process
|
||||
setupWorker(io);
|
||||
|
||||
io.on("connection", (socket) => {
|
||||
/* ... */
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
822
packages/socket.io-cluster-adapter/assets/adapter.excalidraw
Normal file
822
packages/socket.io-cluster-adapter/assets/adapter.excalidraw
Normal file
@@ -0,0 +1,822 @@
|
||||
{
|
||||
"type": "excalidraw",
|
||||
"version": 2,
|
||||
"source": "https://excalidraw.com",
|
||||
"elements": [
|
||||
{
|
||||
"type": "text",
|
||||
"version": 345,
|
||||
"versionNonce": 1782313961,
|
||||
"isDeleted": false,
|
||||
"id": "5hUB5ALUlsn26W0PzU4fM",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 777,
|
||||
"y": -89.5,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 78,
|
||||
"height": 26,
|
||||
"seed": 28708370,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [
|
||||
"_wBO22vaQplcoKyBXbWRC"
|
||||
],
|
||||
"fontSize": 20,
|
||||
"fontFamily": 1,
|
||||
"text": "worker 1",
|
||||
"baseline": 18,
|
||||
"textAlign": "center",
|
||||
"verticalAlign": "middle"
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 230,
|
||||
"versionNonce": 1587305255,
|
||||
"isDeleted": false,
|
||||
"id": "lmQ4o4New7xuXQLwavuSn",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 725,
|
||||
"y": -169,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 345.00000000000006,
|
||||
"height": 311,
|
||||
"seed": 1594950354,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [
|
||||
"_wBO22vaQplcoKyBXbWRC",
|
||||
"BZVwnsrGk9G-X87ZHkh-6",
|
||||
"eU1gfEXnHSjxc-pEgv43A",
|
||||
"XZpY0rnxgeDlxu5b8fgRQ",
|
||||
"4mjxZzapHnLuRx7KU2JeH",
|
||||
"mV8ZNfAcYrxGLJ7b9a_kn"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 152,
|
||||
"versionNonce": 742887113,
|
||||
"isDeleted": false,
|
||||
"id": "ZQsZmj4NaTubBHMkVG2dl",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 745,
|
||||
"y": -159,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 43,
|
||||
"height": 26,
|
||||
"seed": 126533902,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [],
|
||||
"fontSize": 20,
|
||||
"fontFamily": 1,
|
||||
"text": "Host",
|
||||
"baseline": 18,
|
||||
"textAlign": "left",
|
||||
"verticalAlign": "top"
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 334,
|
||||
"versionNonce": 1221877319,
|
||||
"isDeleted": false,
|
||||
"id": "RRrk3Vsl-pM8Z1r8Fj3Vu",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 749.5,
|
||||
"y": -105,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 129,
|
||||
"height": 56,
|
||||
"seed": 1013161166,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [
|
||||
"use4Bp2hbb77Fq5njtwBi",
|
||||
"U7UCkn3nVHlWGYetjII_Z"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 386,
|
||||
"versionNonce": 601673129,
|
||||
"isDeleted": false,
|
||||
"id": "qfQdcJHnwYnCMtLCV51X8",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 773,
|
||||
"y": -18.5,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 90,
|
||||
"height": 26,
|
||||
"seed": 1535426147,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [
|
||||
"_wBO22vaQplcoKyBXbWRC",
|
||||
"2DIFacJXJtC5QIuMuo3pK"
|
||||
],
|
||||
"fontSize": 20,
|
||||
"fontFamily": 1,
|
||||
"text": "worker 2",
|
||||
"baseline": 18,
|
||||
"textAlign": "center",
|
||||
"verticalAlign": "middle"
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 330,
|
||||
"versionNonce": 794754407,
|
||||
"isDeleted": false,
|
||||
"id": "IRd1nPQbv0PQdJQn_yLOs",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 749.5,
|
||||
"y": -36,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 129,
|
||||
"height": 56,
|
||||
"seed": 452398413,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [
|
||||
"2DIFacJXJtC5QIuMuo3pK",
|
||||
"NhqDM6wVMhgbRvXrQJQge",
|
||||
"C1IueNJdiTSkqUxSTEvKe"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 374,
|
||||
"versionNonce": 942092425,
|
||||
"isDeleted": false,
|
||||
"id": "ENOSqQ4visNbCN7ZMZwxP",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 770.5,
|
||||
"y": 48.5,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 89,
|
||||
"height": 26,
|
||||
"seed": 1916984429,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [
|
||||
"_wBO22vaQplcoKyBXbWRC"
|
||||
],
|
||||
"fontSize": 20,
|
||||
"fontFamily": 1,
|
||||
"text": "worker 3",
|
||||
"baseline": 18,
|
||||
"textAlign": "center",
|
||||
"verticalAlign": "middle"
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 314,
|
||||
"versionNonce": 629717127,
|
||||
"isDeleted": false,
|
||||
"id": "IqdB8EO7s50UY1EU9TVVP",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 750.5,
|
||||
"y": 30,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 129,
|
||||
"height": 56,
|
||||
"seed": 1832463587,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [
|
||||
"NhqDM6wVMhgbRvXrQJQge"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 115,
|
||||
"versionNonce": 997860361,
|
||||
"isDeleted": false,
|
||||
"id": "9grXh8d6z3-WENQLWSBP6",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 338,
|
||||
"y": -95,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 140,
|
||||
"height": 49,
|
||||
"seed": 1667334019,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": []
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 95,
|
||||
"versionNonce": 1806744839,
|
||||
"isDeleted": false,
|
||||
"id": "uw4DcwoucyYZxQuvW-XdC",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 383,
|
||||
"y": -83.5,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 50,
|
||||
"height": 26,
|
||||
"seed": 1216901411,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [],
|
||||
"fontSize": 20,
|
||||
"fontFamily": 1,
|
||||
"text": "client",
|
||||
"baseline": 18,
|
||||
"textAlign": "center",
|
||||
"verticalAlign": "middle"
|
||||
},
|
||||
{
|
||||
"id": "ZR4mzBF0WDviz0UhZ4jZM",
|
||||
"type": "diamond",
|
||||
"x": 891.5,
|
||||
"y": -87,
|
||||
"width": 35,
|
||||
"height": 18,
|
||||
"angle": 0,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"seed": 1951590473,
|
||||
"version": 87,
|
||||
"versionNonce": 232917705,
|
||||
"isDeleted": false,
|
||||
"boundElementIds": [
|
||||
"LgoBfF5uxSyzlQnWpzp21",
|
||||
"VzzoutsEZMxQbMloZdWpR",
|
||||
"OEzsLqAW3F-2LE0bnPrtx"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "tpect-oo26kMVbG_xdqoO",
|
||||
"type": "text",
|
||||
"x": 895.5,
|
||||
"y": -130,
|
||||
"width": 157,
|
||||
"height": 26,
|
||||
"angle": 0,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"seed": 294816809,
|
||||
"version": 104,
|
||||
"versionNonce": 2120602793,
|
||||
"isDeleted": false,
|
||||
"boundElementIds": null,
|
||||
"text": "cluster adapter",
|
||||
"fontSize": 20,
|
||||
"fontFamily": 1,
|
||||
"textAlign": "left",
|
||||
"verticalAlign": "top",
|
||||
"baseline": 18
|
||||
},
|
||||
{
|
||||
"type": "diamond",
|
||||
"version": 113,
|
||||
"versionNonce": 1690814889,
|
||||
"isDeleted": false,
|
||||
"id": "ScoFMjrxukGD1efHfKiFH",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 894.5,
|
||||
"y": -20,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 35,
|
||||
"height": 18,
|
||||
"seed": 696687431,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [
|
||||
"VzzoutsEZMxQbMloZdWpR"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "diamond",
|
||||
"version": 158,
|
||||
"versionNonce": 1317846759,
|
||||
"isDeleted": false,
|
||||
"id": "wj2HZ2scg4U6UtpfK8x3e",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 893.5,
|
||||
"y": 46,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 35,
|
||||
"height": 18,
|
||||
"seed": 1469547015,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [
|
||||
"OEzsLqAW3F-2LE0bnPrtx"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "U7UCkn3nVHlWGYetjII_Z",
|
||||
"type": "arrow",
|
||||
"x": 734.5,
|
||||
"y": -74,
|
||||
"width": 238,
|
||||
"height": 4,
|
||||
"angle": 0,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "round",
|
||||
"seed": 1537057031,
|
||||
"version": 61,
|
||||
"versionNonce": 1166788937,
|
||||
"isDeleted": false,
|
||||
"boundElementIds": null,
|
||||
"points": [
|
||||
[
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-238,
|
||||
4
|
||||
]
|
||||
],
|
||||
"lastCommittedPoint": null,
|
||||
"startBinding": {
|
||||
"elementId": "RRrk3Vsl-pM8Z1r8Fj3Vu",
|
||||
"focus": -0.05720889916209189,
|
||||
"gap": 15
|
||||
},
|
||||
"endBinding": null,
|
||||
"startArrowhead": null,
|
||||
"endArrowhead": "arrow"
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 163,
|
||||
"versionNonce": 15141831,
|
||||
"isDeleted": false,
|
||||
"id": "mv6FEWy7Oux1XBpOeYKlJ",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 337.25,
|
||||
"y": -26.5,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 140,
|
||||
"height": 49,
|
||||
"seed": 1927924585,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": []
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 143,
|
||||
"versionNonce": 766883881,
|
||||
"isDeleted": false,
|
||||
"id": "sBk2P5AAiZa36HbnmeRLi",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 382.25,
|
||||
"y": -15,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 50,
|
||||
"height": 26,
|
||||
"seed": 1643756455,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [],
|
||||
"fontSize": 20,
|
||||
"fontFamily": 1,
|
||||
"text": "client",
|
||||
"baseline": 18,
|
||||
"textAlign": "center",
|
||||
"verticalAlign": "middle"
|
||||
},
|
||||
{
|
||||
"type": "arrow",
|
||||
"version": 111,
|
||||
"versionNonce": 2076179175,
|
||||
"isDeleted": false,
|
||||
"id": "C1IueNJdiTSkqUxSTEvKe",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 733.75,
|
||||
"y": -5.5,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 238,
|
||||
"height": 4,
|
||||
"seed": 542013001,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "round",
|
||||
"boundElementIds": [],
|
||||
"startBinding": {
|
||||
"elementId": "IRd1nPQbv0PQdJQn_yLOs",
|
||||
"focus": -0.03958393527882115,
|
||||
"gap": 15.75
|
||||
},
|
||||
"endBinding": null,
|
||||
"lastCommittedPoint": null,
|
||||
"startArrowhead": null,
|
||||
"endArrowhead": "arrow",
|
||||
"points": [
|
||||
[
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-238,
|
||||
4
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 138,
|
||||
"versionNonce": 478071561,
|
||||
"isDeleted": false,
|
||||
"id": "6r_-m_ehoDx3FlKI9YqbJ",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 337.25,
|
||||
"y": 40.5,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 140,
|
||||
"height": 49,
|
||||
"seed": 704870919,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": []
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 118,
|
||||
"versionNonce": 133039623,
|
||||
"isDeleted": false,
|
||||
"id": "EEhePeT66oko7kRekPQGo",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 382.25,
|
||||
"y": 52,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 50,
|
||||
"height": 26,
|
||||
"seed": 93212137,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [],
|
||||
"fontSize": 20,
|
||||
"fontFamily": 1,
|
||||
"text": "client",
|
||||
"baseline": 18,
|
||||
"textAlign": "center",
|
||||
"verticalAlign": "middle"
|
||||
},
|
||||
{
|
||||
"type": "arrow",
|
||||
"version": 86,
|
||||
"versionNonce": 979534313,
|
||||
"isDeleted": false,
|
||||
"id": "etOb8BtJX8fUgxXsPOX2F",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 733.75,
|
||||
"y": 61.5,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 238,
|
||||
"height": 4,
|
||||
"seed": 464822567,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "round",
|
||||
"boundElementIds": [],
|
||||
"startBinding": null,
|
||||
"endBinding": null,
|
||||
"lastCommittedPoint": null,
|
||||
"startArrowhead": null,
|
||||
"endArrowhead": "arrow",
|
||||
"points": [
|
||||
[
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-238,
|
||||
4
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 184,
|
||||
"versionNonce": 1953344807,
|
||||
"isDeleted": false,
|
||||
"id": "G6-PJf8TRngnFyuC3A0QC",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 337.25,
|
||||
"y": 105.5,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 140,
|
||||
"height": 49,
|
||||
"seed": 1627945223,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [
|
||||
"JFhaNprFAz7gl6FY48Aps"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 163,
|
||||
"versionNonce": 342645961,
|
||||
"isDeleted": false,
|
||||
"id": "UEv3oUzBr56Mj6Mz7hG-B",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 382.25,
|
||||
"y": 117,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 50,
|
||||
"height": 26,
|
||||
"seed": 1822211817,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "sharp",
|
||||
"boundElementIds": [],
|
||||
"fontSize": 20,
|
||||
"fontFamily": 1,
|
||||
"text": "client",
|
||||
"baseline": 18,
|
||||
"textAlign": "center",
|
||||
"verticalAlign": "middle"
|
||||
},
|
||||
{
|
||||
"type": "arrow",
|
||||
"version": 135,
|
||||
"versionNonce": 2091610183,
|
||||
"isDeleted": false,
|
||||
"id": "JFhaNprFAz7gl6FY48Aps",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 731.1770639400929,
|
||||
"y": 74.303452225402,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 240.42706394009292,
|
||||
"height": 54.196547774598,
|
||||
"seed": 1203879975,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "round",
|
||||
"boundElementIds": [],
|
||||
"startBinding": null,
|
||||
"endBinding": {
|
||||
"elementId": "G6-PJf8TRngnFyuC3A0QC",
|
||||
"focus": 0.4300574064368146,
|
||||
"gap": 13.5
|
||||
},
|
||||
"lastCommittedPoint": null,
|
||||
"startArrowhead": null,
|
||||
"endArrowhead": "arrow",
|
||||
"points": [
|
||||
[
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-240.42706394009292,
|
||||
54.196547774598
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "VzzoutsEZMxQbMloZdWpR",
|
||||
"type": "arrow",
|
||||
"x": 929.5,
|
||||
"y": -70,
|
||||
"width": 17,
|
||||
"height": 53,
|
||||
"angle": 0,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "round",
|
||||
"seed": 1957283401,
|
||||
"version": 330,
|
||||
"versionNonce": 1093640775,
|
||||
"isDeleted": false,
|
||||
"boundElementIds": null,
|
||||
"points": [
|
||||
[
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
16,
|
||||
23
|
||||
],
|
||||
[
|
||||
-1,
|
||||
53
|
||||
]
|
||||
],
|
||||
"lastCommittedPoint": null,
|
||||
"startBinding": {
|
||||
"elementId": "ZR4mzBF0WDviz0UhZ4jZM",
|
||||
"focus": -0.853416149068323,
|
||||
"gap": 8.48634645640746
|
||||
},
|
||||
"endBinding": {
|
||||
"elementId": "ScoFMjrxukGD1efHfKiFH",
|
||||
"focus": 0.7485714285714284,
|
||||
"gap": 4.878378801288122
|
||||
},
|
||||
"startArrowhead": null,
|
||||
"endArrowhead": "arrow"
|
||||
},
|
||||
{
|
||||
"type": "arrow",
|
||||
"version": 440,
|
||||
"versionNonce": 2038871081,
|
||||
"isDeleted": false,
|
||||
"id": "OEzsLqAW3F-2LE0bnPrtx",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 1,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 1,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 930.5,
|
||||
"y": -71,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 42,
|
||||
"height": 116,
|
||||
"seed": 1990607913,
|
||||
"groupIds": [],
|
||||
"strokeSharpness": "round",
|
||||
"boundElementIds": [],
|
||||
"startBinding": {
|
||||
"elementId": "ZR4mzBF0WDviz0UhZ4jZM",
|
||||
"focus": -0.8894409937888198,
|
||||
"gap": 8.054406666710076
|
||||
},
|
||||
"endBinding": {
|
||||
"elementId": "wj2HZ2scg4U6UtpfK8x3e",
|
||||
"focus": 0.6,
|
||||
"gap": 8.435530010560711
|
||||
},
|
||||
"lastCommittedPoint": null,
|
||||
"startArrowhead": null,
|
||||
"endArrowhead": "arrow",
|
||||
"points": [
|
||||
[
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
39,
|
||||
46
|
||||
],
|
||||
[
|
||||
-3,
|
||||
116
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
"appState": {
|
||||
"gridSize": null,
|
||||
"viewBackgroundColor": "#ffffff"
|
||||
}
|
||||
}
|
||||
BIN
packages/socket.io-cluster-adapter/assets/adapter.png
Normal file
BIN
packages/socket.io-cluster-adapter/assets/adapter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
116
packages/socket.io-cluster-adapter/lib/index.ts
Normal file
116
packages/socket.io-cluster-adapter/lib/index.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import cluster from "node:cluster";
|
||||
import {
|
||||
ClusterAdapterWithHeartbeat,
|
||||
ClusterAdapterOptions,
|
||||
ClusterMessage,
|
||||
ServerId,
|
||||
ClusterResponse,
|
||||
MessageType,
|
||||
} from "socket.io-adapter";
|
||||
import debugModule from "debug";
|
||||
|
||||
const debug = debugModule("socket.io-cluster-adapter");
|
||||
const MESSAGE_SOURCE = "_sio_adapter";
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
function ignoreError() {}
|
||||
|
||||
/**
|
||||
* Returns a function that will create a NodeClusterAdapter instance.
|
||||
*
|
||||
* @param opts - additional options
|
||||
*
|
||||
* @public
|
||||
* @see https://nodejs.org/api/cluster.html
|
||||
*/
|
||||
export function createAdapter(opts: Partial<ClusterAdapterOptions> = {}) {
|
||||
return function (nsp: any) {
|
||||
return new NodeClusterAdapter(nsp, opts);
|
||||
};
|
||||
}
|
||||
|
||||
export class NodeClusterAdapter extends ClusterAdapterWithHeartbeat {
|
||||
constructor(nsp: any, opts: ClusterAdapterOptions = {}) {
|
||||
super(nsp, opts);
|
||||
process.on("message", (message: any) => {
|
||||
const isValidSource = message?.source === MESSAGE_SOURCE;
|
||||
if (!isValidSource) {
|
||||
debug("[%s] ignore unknown source", this.uid);
|
||||
return;
|
||||
}
|
||||
|
||||
// note: this check should be done in the onMessage() handler
|
||||
if (message.nsp !== this.nsp.name) {
|
||||
debug("[%s] ignore other namespace", this.uid);
|
||||
return;
|
||||
}
|
||||
|
||||
this.onMessage(message);
|
||||
});
|
||||
|
||||
// until https://github.com/socketio/socket.io/commit/f3e1f5ebdf59158d0c8d1e20f8230275617fb355 is released
|
||||
this.init();
|
||||
}
|
||||
|
||||
protected override doPublish(message: ClusterMessage & { source: string }) {
|
||||
message.source = MESSAGE_SOURCE;
|
||||
|
||||
process.send(message, null, {}, ignoreError);
|
||||
|
||||
return Promise.resolve(""); // connection state recovery is not supported
|
||||
}
|
||||
|
||||
protected override doPublishResponse(
|
||||
requesterUid: ServerId,
|
||||
response: ClusterResponse & { source: string; requesterUid: string },
|
||||
) {
|
||||
response.source = MESSAGE_SOURCE;
|
||||
response.requesterUid = requesterUid;
|
||||
|
||||
process.send(response, null, {}, ignoreError);
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
const UIDS = Symbol("uids");
|
||||
|
||||
export function setupPrimary() {
|
||||
cluster.on("message", (worker, message) => {
|
||||
const isValidSource = message?.source === MESSAGE_SOURCE;
|
||||
if (!isValidSource) {
|
||||
return;
|
||||
}
|
||||
|
||||
// store the requester's uids (one per namespace) so that the response can be sent specifically to them
|
||||
worker[UIDS] = worker[UIDS] || new Set();
|
||||
worker[UIDS].add(message.uid);
|
||||
|
||||
switch (message.type) {
|
||||
case MessageType.FETCH_SOCKETS_RESPONSE:
|
||||
case MessageType.SERVER_SIDE_EMIT_RESPONSE:
|
||||
const requesterUid = message.requesterUid;
|
||||
for (const workerId in cluster.workers) {
|
||||
if (
|
||||
hasOwnProperty.call(cluster.workers, workerId) &&
|
||||
cluster.workers[workerId][UIDS]?.has(requesterUid)
|
||||
) {
|
||||
cluster.workers[workerId].send(message, null, ignoreError);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
const emitterIdAsString = String(worker.id);
|
||||
// emit to all workers but the requester
|
||||
for (const workerId in cluster.workers) {
|
||||
if (
|
||||
hasOwnProperty.call(cluster.workers, workerId) &&
|
||||
workerId !== emitterIdAsString
|
||||
) {
|
||||
cluster.workers[workerId].send(message, null, ignoreError);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
3345
packages/socket.io-cluster-adapter/package-lock.json
generated
Normal file
3345
packages/socket.io-cluster-adapter/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
35
packages/socket.io-cluster-adapter/package.json
Normal file
35
packages/socket.io-cluster-adapter/package.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@socket.io/cluster-adapter",
|
||||
"version": "0.2.2",
|
||||
"description": "The Socket.IO cluster adapter, allowing to broadcast events between several Socket.IO servers",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:socketio/socket.io-cluster-adapter.git"
|
||||
},
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "npm run format:check && tsc && nyc mocha --import=tsx test/index.ts",
|
||||
"format:check": "prettier --check 'lib/**/*.ts' 'test/**/*.ts'",
|
||||
"format:fix": "prettier --write 'lib/**/*.ts' 'test/**/*.ts'",
|
||||
"prepack": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "~4.4.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"socket.io-adapter": "~2.5.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"socket.io",
|
||||
"cluster",
|
||||
"adapter"
|
||||
]
|
||||
}
|
||||
372
packages/socket.io-cluster-adapter/test/index.ts
Normal file
372
packages/socket.io-cluster-adapter/test/index.ts
Normal file
@@ -0,0 +1,372 @@
|
||||
import { io as ioc, Socket as ClientSocket } from "socket.io-client";
|
||||
import expect = require("expect.js");
|
||||
import { setupPrimary } from "..";
|
||||
import { times, sleep } from "./util";
|
||||
import cluster, { Worker } from "node:cluster";
|
||||
|
||||
const NODES_COUNT = 3;
|
||||
|
||||
cluster.setupMaster({
|
||||
exec: "./test/worker.js",
|
||||
// @ts-ignore
|
||||
serialization: "advanced", // needed for packets containing buffers
|
||||
});
|
||||
|
||||
setupPrimary();
|
||||
|
||||
const getRooms = (worker): Promise<Set<string>> => {
|
||||
worker.send("get rooms");
|
||||
return new Promise((resolve) => {
|
||||
worker.once("message", (content) => {
|
||||
resolve(content);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
describe("@socket.io/cluster-adapter", () => {
|
||||
let clientSockets: ClientSocket[], workers: Worker[];
|
||||
|
||||
beforeEach((done) => {
|
||||
clientSockets = [];
|
||||
workers = [];
|
||||
|
||||
for (let i = 1; i <= NODES_COUNT; i++) {
|
||||
const PORT = 40000 + i;
|
||||
const worker = cluster.fork({
|
||||
PORT,
|
||||
});
|
||||
|
||||
worker.on("listening", () => {
|
||||
const clientSocket = ioc(`http://localhost:${PORT}`);
|
||||
|
||||
clientSocket.on("connect", async () => {
|
||||
workers.push(worker);
|
||||
clientSockets.push(clientSocket);
|
||||
if (clientSockets.length === NODES_COUNT) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
for (const id in cluster.workers) {
|
||||
cluster.workers[id].kill();
|
||||
}
|
||||
clientSockets.forEach((socket) => {
|
||||
socket.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("broadcast", function () {
|
||||
it("broadcasts to all clients", (done) => {
|
||||
const partialDone = times(3, done);
|
||||
|
||||
clientSockets.forEach((clientSocket) => {
|
||||
clientSocket.on("test", (arg1, arg2, arg3) => {
|
||||
expect(arg1).to.eql(1);
|
||||
expect(arg2).to.eql("2");
|
||||
expect(Buffer.isBuffer(arg3)).to.be(true);
|
||||
partialDone();
|
||||
});
|
||||
});
|
||||
|
||||
workers[0].send("broadcasts to all clients");
|
||||
});
|
||||
|
||||
it("broadcasts to all clients in a namespace", (done) => {
|
||||
const partialDone = times(3, done);
|
||||
|
||||
const onConnect = times(3, async () => {
|
||||
workers[0].send("broadcasts to all clients in a namespace");
|
||||
});
|
||||
|
||||
clientSockets.forEach((clientSocket) => {
|
||||
const socket = clientSocket.io.socket("/custom");
|
||||
socket.on("connect", onConnect);
|
||||
socket.on("test", () => {
|
||||
socket.disconnect();
|
||||
partialDone();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("broadcasts to all clients in a room", (done) => {
|
||||
workers[1].send("join room1");
|
||||
|
||||
clientSockets[0].on("test", () => {
|
||||
done(new Error("should not happen"));
|
||||
});
|
||||
|
||||
clientSockets[1].on("test", () => {
|
||||
done();
|
||||
});
|
||||
|
||||
clientSockets[2].on("test", () => {
|
||||
done(new Error("should not happen"));
|
||||
});
|
||||
|
||||
workers[0].send("broadcasts to all clients in a room");
|
||||
});
|
||||
|
||||
it("broadcasts to all clients except in room", (done) => {
|
||||
const partialDone = times(2, done);
|
||||
workers[1].send("join room1");
|
||||
|
||||
clientSockets[0].on("test", () => {
|
||||
partialDone();
|
||||
});
|
||||
|
||||
clientSockets[1].on("test", () => {
|
||||
done(new Error("should not happen"));
|
||||
});
|
||||
|
||||
clientSockets[2].on("test", () => {
|
||||
partialDone();
|
||||
});
|
||||
|
||||
workers[0].send("broadcasts to all clients except in room");
|
||||
});
|
||||
|
||||
it("broadcasts to local clients only", (done) => {
|
||||
clientSockets[0].on("test", () => {
|
||||
done();
|
||||
});
|
||||
|
||||
clientSockets[1].on("test", () => {
|
||||
done(new Error("should not happen"));
|
||||
});
|
||||
|
||||
clientSockets[2].on("test", () => {
|
||||
done(new Error("should not happen"));
|
||||
});
|
||||
|
||||
workers[0].send("broadcasts to local clients only");
|
||||
});
|
||||
|
||||
it("broadcasts with multiple acknowledgements", (done) => {
|
||||
clientSockets[0].on("test", (cb) => {
|
||||
cb(1);
|
||||
});
|
||||
|
||||
clientSockets[1].on("test", (cb) => {
|
||||
cb(2);
|
||||
});
|
||||
|
||||
clientSockets[2].on("test", (cb) => {
|
||||
cb(3);
|
||||
});
|
||||
|
||||
workers[0].send("broadcasts with multiple acknowledgements");
|
||||
|
||||
workers[0].on("message", (result) => {
|
||||
if (result === "ok") {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("broadcasts with multiple acknowledgements (binary content)", (done) => {
|
||||
clientSockets[0].on("test", (cb) => {
|
||||
cb(Buffer.from([1]));
|
||||
});
|
||||
|
||||
clientSockets[1].on("test", (cb) => {
|
||||
cb(Buffer.from([2]));
|
||||
});
|
||||
|
||||
clientSockets[2].on("test", (cb) => {
|
||||
cb(Buffer.from([3]));
|
||||
});
|
||||
|
||||
workers[0].send(
|
||||
"broadcasts with multiple acknowledgements (binary content)",
|
||||
);
|
||||
|
||||
workers[0].on("message", (result) => {
|
||||
if (result === "ok") {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("broadcasts with multiple acknowledgements (no client)", (done) => {
|
||||
workers[0].send("broadcasts with multiple acknowledgements (no client)");
|
||||
|
||||
workers[0].on("message", (result) => {
|
||||
if (result === "ok") {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("broadcasts with multiple acknowledgements (timeout)", (done) => {
|
||||
clientSockets[0].on("test", (cb) => {
|
||||
cb(1);
|
||||
});
|
||||
|
||||
clientSockets[1].on("test", (cb) => {
|
||||
cb(2);
|
||||
});
|
||||
|
||||
clientSockets[2].on("test", (cb) => {
|
||||
// do nothing
|
||||
});
|
||||
|
||||
workers[0].send("broadcasts with multiple acknowledgements (timeout)");
|
||||
|
||||
workers[0].on("message", (result) => {
|
||||
if (result === "ok") {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("socketsJoin", () => {
|
||||
it("makes all socket instances join the specified room", async () => {
|
||||
workers[0].send("makes all socket instances join the specified room");
|
||||
|
||||
await sleep(100);
|
||||
|
||||
expect((await getRooms(workers[0])).has("room1")).to.be(true);
|
||||
expect((await getRooms(workers[1])).has("room1")).to.be(true);
|
||||
expect((await getRooms(workers[2])).has("room1")).to.be(true);
|
||||
});
|
||||
|
||||
it("makes the matching socket instances join the specified room", async () => {
|
||||
workers[0].send("join room1");
|
||||
workers[2].send("join room1");
|
||||
|
||||
workers[0].send(
|
||||
"makes the matching socket instances join the specified room",
|
||||
);
|
||||
|
||||
await sleep(100);
|
||||
|
||||
expect((await getRooms(workers[0])).has("room2")).to.be(true);
|
||||
expect((await getRooms(workers[1])).has("room2")).to.be(false);
|
||||
expect((await getRooms(workers[2])).has("room2")).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("socketsLeave", () => {
|
||||
it("makes all socket instances leave the specified room", async () => {
|
||||
workers[0].send("join room1");
|
||||
workers[2].send("join room1");
|
||||
|
||||
workers[0].send("makes all socket instances leave the specified room");
|
||||
|
||||
await sleep(100);
|
||||
|
||||
expect((await getRooms(workers[0])).has("room1")).to.be(false);
|
||||
expect((await getRooms(workers[1])).has("room1")).to.be(false);
|
||||
expect((await getRooms(workers[2])).has("room1")).to.be(false);
|
||||
});
|
||||
|
||||
it("makes the matching socket instances leave the specified room", async () => {
|
||||
workers[0].send("join room1 & room2");
|
||||
workers[2].send("join room2");
|
||||
|
||||
workers[0].send(
|
||||
"makes the matching socket instances leave the specified room",
|
||||
);
|
||||
|
||||
await sleep(100);
|
||||
|
||||
expect((await getRooms(workers[0])).has("room2")).to.be(false);
|
||||
expect((await getRooms(workers[1])).has("room2")).to.be(false);
|
||||
expect((await getRooms(workers[2])).has("room2")).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("disconnectSockets", () => {
|
||||
it("makes all socket instances disconnect", (done) => {
|
||||
const partialDone = times(3, done);
|
||||
|
||||
clientSockets.forEach((clientSocket) => {
|
||||
clientSocket.on("disconnect", (reason) => {
|
||||
expect(reason).to.eql("io server disconnect");
|
||||
partialDone();
|
||||
});
|
||||
});
|
||||
|
||||
workers[0].send("makes all socket instances disconnect");
|
||||
});
|
||||
});
|
||||
|
||||
describe("fetchSockets", () => {
|
||||
it("returns all socket instances", (done) => {
|
||||
workers[0].send("returns all socket instances");
|
||||
|
||||
workers[0].on("message", (result) => {
|
||||
if (result === "ok") {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("serverSideEmit", () => {
|
||||
it("sends an event to other server instances", (done) => {
|
||||
const partialDone = times(2, done);
|
||||
|
||||
workers[0].send("sends an event to other server instances");
|
||||
|
||||
workers[0].on("message", (result) => {
|
||||
if (result === "ok") {
|
||||
done(new Error("should not happen"));
|
||||
}
|
||||
});
|
||||
|
||||
workers[1].on("message", (result) => {
|
||||
expect(result).to.eql("ok");
|
||||
partialDone();
|
||||
});
|
||||
|
||||
workers[2].on("message", (result) => {
|
||||
expect(result).to.eql("ok");
|
||||
partialDone();
|
||||
});
|
||||
});
|
||||
|
||||
it("sends an event and receives a response from the other server instances", (done) => {
|
||||
workers[0].send(
|
||||
"sends an event and receives a response from the other server instances (1)",
|
||||
);
|
||||
workers[1].send(
|
||||
"sends an event and receives a response from the other server instances (2)",
|
||||
);
|
||||
workers[2].send(
|
||||
"sends an event and receives a response from the other server instances (3)",
|
||||
);
|
||||
|
||||
workers[0].on("message", (result) => {
|
||||
if (result === "ok") {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("sends an event but timeout if one server does not respond", function (done) {
|
||||
this.timeout(6000); // currently not possible to configure the timeout delay
|
||||
|
||||
workers[0].send(
|
||||
"sends an event but timeout if one server does not respond (1)",
|
||||
);
|
||||
workers[1].send(
|
||||
"sends an event but timeout if one server does not respond (2)",
|
||||
);
|
||||
workers[2].send(
|
||||
"sends an event but timeout if one server does not respond (3)",
|
||||
);
|
||||
|
||||
workers[0].on("message", (result) => {
|
||||
if (result === "ok") {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
13
packages/socket.io-cluster-adapter/test/util.ts
Normal file
13
packages/socket.io-cluster-adapter/test/util.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export function times(count: number, fn: () => void) {
|
||||
let i = 0;
|
||||
return () => {
|
||||
i++;
|
||||
if (i === count) {
|
||||
fn();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function sleep(duration: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, duration));
|
||||
}
|
||||
182
packages/socket.io-cluster-adapter/test/worker.js
Normal file
182
packages/socket.io-cluster-adapter/test/worker.js
Normal file
@@ -0,0 +1,182 @@
|
||||
const { createServer } = require("http");
|
||||
const { Server } = require("socket.io");
|
||||
const { createAdapter } = require("..");
|
||||
|
||||
const httpServer = createServer();
|
||||
const io = new Server(httpServer);
|
||||
const expect = require("expect.js");
|
||||
|
||||
io.adapter(createAdapter());
|
||||
|
||||
let serverSocket;
|
||||
|
||||
io.on("connection", (socket) => {
|
||||
serverSocket = socket;
|
||||
});
|
||||
|
||||
const customNamespace = io.of("/custom");
|
||||
|
||||
process.on("message", async (msg) => {
|
||||
switch (msg) {
|
||||
case "broadcasts to all clients":
|
||||
io.emit("test", 1, "2", Buffer.from([3, 4]));
|
||||
break;
|
||||
case "broadcasts to all clients in a namespace":
|
||||
customNamespace.emit("test");
|
||||
break;
|
||||
case "join room1":
|
||||
serverSocket.join("room1");
|
||||
break;
|
||||
case "join room1 & room2":
|
||||
serverSocket.join(["room1", "room2"]);
|
||||
break;
|
||||
case "join room2":
|
||||
serverSocket.join("room2");
|
||||
break;
|
||||
case "broadcasts to all clients in a room":
|
||||
io.to("room1").emit("test");
|
||||
break;
|
||||
case "broadcasts to all clients except in room":
|
||||
io.of("/").except("room1").emit("test");
|
||||
break;
|
||||
case "broadcasts to local clients only":
|
||||
io.local.emit("test");
|
||||
break;
|
||||
|
||||
case "broadcasts with multiple acknowledgements": {
|
||||
io.timeout(500).emit("test", (err, responses) => {
|
||||
expect(err).to.be(null);
|
||||
expect(responses).to.contain(1);
|
||||
expect(responses).to.contain(2);
|
||||
expect(responses).to.contain(3);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(io.of("/").adapter.ackRequests.size).to.eql(0);
|
||||
|
||||
process.send("ok");
|
||||
}, 500);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case "broadcasts with multiple acknowledgements (binary content)": {
|
||||
io.timeout(500).emit("test", (err, responses) => {
|
||||
expect(err).to.be(null);
|
||||
responses.forEach((response) => {
|
||||
expect(Buffer.isBuffer(response)).to.be(true);
|
||||
});
|
||||
|
||||
process.send("ok");
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case "broadcasts with multiple acknowledgements (no client)": {
|
||||
io
|
||||
.to("abc")
|
||||
.timeout(500)
|
||||
.emit("test", (err, responses) => {
|
||||
expect(err).to.be(null);
|
||||
expect(responses).to.eql([]);
|
||||
|
||||
process.send("ok");
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case "broadcasts with multiple acknowledgements (timeout)": {
|
||||
io.timeout(500).emit("test", (err, responses) => {
|
||||
expect(err).to.be.an(Error);
|
||||
expect(responses).to.contain(1);
|
||||
expect(responses).to.contain(2);
|
||||
|
||||
process.send("ok");
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case "get rooms":
|
||||
process.send(serverSocket.rooms);
|
||||
break;
|
||||
case "makes all socket instances join the specified room":
|
||||
io.socketsJoin("room1");
|
||||
break;
|
||||
|
||||
case "makes the matching socket instances join the specified room":
|
||||
io.in("room1").socketsJoin("room2");
|
||||
break;
|
||||
|
||||
case "makes all socket instances leave the specified room":
|
||||
io.socketsLeave("room1");
|
||||
break;
|
||||
case "makes the matching socket instances leave the specified room":
|
||||
io.in("room1").socketsLeave("room2");
|
||||
break;
|
||||
|
||||
case "makes all socket instances disconnect":
|
||||
io.disconnectSockets();
|
||||
break;
|
||||
|
||||
case "returns all socket instances":
|
||||
const sockets = await io.fetchSockets();
|
||||
|
||||
expect(sockets).to.be.an(Array);
|
||||
expect(sockets).to.have.length(3);
|
||||
expect(io.of("/").adapter.requests.size).to.eql(0); // clean up
|
||||
|
||||
process.send("ok");
|
||||
break;
|
||||
|
||||
case "sends an event to other server instances":
|
||||
io.serverSideEmit("hello", "world", 1, "2");
|
||||
break;
|
||||
case "sends an event and receives a response from the other server instances (1)":
|
||||
io.serverSideEmit("hello with ack", (err, response) => {
|
||||
expect(err).to.be(null);
|
||||
expect(response).to.be.an(Array);
|
||||
expect(response).to.contain(2);
|
||||
expect(response).to.contain("3");
|
||||
process.send("ok");
|
||||
});
|
||||
break;
|
||||
case "sends an event and receives a response from the other server instances (2)":
|
||||
io.on("hello with ack", (cb) => {
|
||||
cb(2);
|
||||
});
|
||||
break;
|
||||
case "sends an event and receives a response from the other server instances (3)":
|
||||
io.on("hello with ack", (cb) => {
|
||||
cb("3");
|
||||
});
|
||||
break;
|
||||
case "sends an event but timeout if one server does not respond (1)":
|
||||
io.serverSideEmit("hello with ack", (err, response) => {
|
||||
expect(err.message).to.be(
|
||||
"timeout reached: missing 1 responses"
|
||||
);
|
||||
expect(response).to.be.an(Array);
|
||||
expect(response).to.contain(2);
|
||||
process.send("ok");
|
||||
});
|
||||
break;
|
||||
case "sends an event but timeout if one server does not respond (2)":
|
||||
io.on("hello with ack", (cb) => {
|
||||
cb(2);
|
||||
});
|
||||
break;
|
||||
case "sends an event but timeout if one server does not respond (3)":
|
||||
io.on("hello with ack", (cb) => {
|
||||
// do nothing
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
io.on("hello", (arg1, arg2, arg3) => {
|
||||
expect(arg1).to.eql("world");
|
||||
expect(arg2).to.eql(1);
|
||||
expect(arg3).to.eql("2");
|
||||
process.send("ok");
|
||||
});
|
||||
|
||||
httpServer.listen(parseInt(process.env.PORT, 10));
|
||||
13
packages/socket.io-cluster-adapter/tsconfig.json
Normal file
13
packages/socket.io-cluster-adapter/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"allowJs": false,
|
||||
"target": "es2017",
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"include": [
|
||||
"./lib/**/*"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user