@cocreate/socket-server 1.31.1 → 1.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/automated.yml +26 -39
- package/CHANGELOG.md +33 -0
- package/README.md +136 -37
- package/denotest.json +8 -0
- package/package.json +17 -25
- package/release.config.js +13 -5
- package/src/index.js +837 -638
- package/src/mesh.js +0 -71
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
name: Automated Workflow
|
|
2
|
+
|
|
2
3
|
on:
|
|
3
4
|
push:
|
|
4
5
|
branches:
|
|
5
|
-
-
|
|
6
|
+
- main
|
|
7
|
+
|
|
6
8
|
jobs:
|
|
7
9
|
about:
|
|
8
10
|
runs-on: ubuntu-latest
|
|
@@ -18,52 +20,37 @@ jobs:
|
|
|
18
20
|
with:
|
|
19
21
|
direction: overwrite-github
|
|
20
22
|
githubToken: "${{ secrets.GITHUB }}"
|
|
23
|
+
|
|
21
24
|
release:
|
|
22
25
|
runs-on: ubuntu-latest
|
|
23
26
|
steps:
|
|
24
27
|
- name: Checkout
|
|
25
|
-
uses: actions/checkout@
|
|
26
|
-
- name: Setup Node.js
|
|
27
|
-
uses: actions/setup-node@v3
|
|
28
|
+
uses: actions/checkout@v4
|
|
28
29
|
with:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
fetch-depth: 0 # Required so semantic-release can trace git tags/history
|
|
31
|
+
|
|
32
|
+
- name: Setup Node.js
|
|
33
|
+
uses: actions/setup-node@v4
|
|
33
34
|
with:
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
node-version: 22
|
|
36
|
+
|
|
37
|
+
- name: Install Semantic Release & Plugins
|
|
38
|
+
# Installs semantic-release and its plugins on the runner
|
|
39
|
+
run: |
|
|
40
|
+
npm install -g semantic-release \
|
|
41
|
+
@semantic-release/changelog \
|
|
42
|
+
@semantic-release/npm \
|
|
43
|
+
@semantic-release/github \
|
|
36
44
|
@semantic-release/git
|
|
37
|
-
|
|
45
|
+
|
|
46
|
+
- name: Run Semantic Release (Native)
|
|
47
|
+
id: semantic
|
|
48
|
+
# This will automatically pick up your export default config file in the repository root
|
|
49
|
+
run: npx semantic-release
|
|
38
50
|
env:
|
|
39
|
-
GITHUB_TOKEN: "${{ secrets.
|
|
51
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
40
52
|
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
53
|
+
|
|
41
54
|
outputs:
|
|
42
55
|
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
|
43
|
-
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
|
44
|
-
upload:
|
|
45
|
-
runs-on: ubuntu-latest
|
|
46
|
-
needs: release
|
|
47
|
-
if: needs.release.outputs.new_release_published == 'true'
|
|
48
|
-
env:
|
|
49
|
-
VERSION: "${{ needs.release.outputs.new_release_version }}"
|
|
50
|
-
steps:
|
|
51
|
-
- name: Checkout
|
|
52
|
-
uses: actions/checkout@v3
|
|
53
|
-
- name: Setup Node.js
|
|
54
|
-
uses: actions/setup-node@v3
|
|
55
|
-
with:
|
|
56
|
-
node-version: 16
|
|
57
|
-
- name: Set npm registry auth
|
|
58
|
-
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
|
|
59
|
-
- name: Install dependencies
|
|
60
|
-
run: yarn install
|
|
61
|
-
|
|
62
|
-
- name: Set Environment Variables
|
|
63
|
-
run: |
|
|
64
|
-
echo "organization_id=${{ secrets.COCREATE_ORGANIZATION_ID }}" >> $GITHUB_ENV
|
|
65
|
-
echo "key=${{ secrets.COCREATE_KEY }}" >> $GITHUB_ENV
|
|
66
|
-
echo "host=${{ secrets.COCREATE_HOST }}" >> $GITHUB_ENV
|
|
67
|
-
- name: CoCreate Upload
|
|
68
|
-
run: coc upload
|
|
69
|
-
|
|
56
|
+
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
# [1.33.0](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.32.0...v1.33.0) (2026-07-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update branch references from master to main in workflow and configuration files ([2148193](https://github.com/CoCreate-app/CoCreate-socket-server/commit/2148193e0471a193abf8443e6adef3b8b75a4d70))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add process-level events for organization eviction and cleanup in SocketServer ([fcbe3a2](https://github.com/CoCreate-app/CoCreate-socket-server/commit/fcbe3a24eb87af3bc9d112cfff31f7e7df2c9af2))
|
|
12
|
+
* enhance SocketServer with server reference caching and improved organization management ([2b8daaf](https://github.com/CoCreate-app/CoCreate-socket-server/commit/2b8daafe0a43497be5144f03af562e11b12a2970))
|
|
13
|
+
* rename bandwidth events to usage for clarity in socket message handling ([8f2f549](https://github.com/CoCreate-app/CoCreate-socket-server/commit/8f2f549c031224a29d7d2daf11636cf8688c75dc))
|
|
14
|
+
* update automated workflow and release configuration for improved semantic release handling ([5b8659f](https://github.com/CoCreate-app/CoCreate-socket-server/commit/5b8659ff2430ad0029bea4b740832917429bb548))
|
|
15
|
+
|
|
16
|
+
# [1.32.0](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.31.1...v1.32.0) (2026-07-14)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* remove unused mesh.js file and related socket handling logic ([b0cab03](https://github.com/CoCreate-app/CoCreate-socket-server/commit/b0cab03c4c106c109c0d9c13157ae118f6189ef5))
|
|
22
|
+
* removed post install ([c1462c3](https://github.com/CoCreate-app/CoCreate-socket-server/commit/c1462c3874bac9b24444d69334a8a80ee74d4b4f))
|
|
23
|
+
* semantic version handling. Reorganize .gitignore for improved clarity and structure ([3a04ef8](https://github.com/CoCreate-app/CoCreate-socket-server/commit/3a04ef83a5db2aadd96cee6374c8c19129d3aaf2))
|
|
24
|
+
* update module export to ES6 syntax in release.config.js ([958adb2](https://github.com/CoCreate-app/CoCreate-socket-server/commit/958adb2fc45e6828f494def07e57c654f8bd105e))
|
|
25
|
+
* update package.json and refactor for module compatibility ([618fae4](https://github.com/CoCreate-app/CoCreate-socket-server/commit/618fae440238f9196415c2702e2b13a9d231fb15))
|
|
26
|
+
* update WebSocket import for compatibility across module systems ([a8e270a](https://github.com/CoCreate-app/CoCreate-socket-server/commit/a8e270aaeb71b93d7b0a777dcb7ebafa5008bfa5))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* implement heartbeat mechanism for socket connections and enhance organization/client management ([568fb3e](https://github.com/CoCreate-app/CoCreate-socket-server/commit/568fb3efc27da677fb298b3035fe7638d7435440))
|
|
32
|
+
* streamline SocketServer initialization and enhance error handling ([3d102e1](https://github.com/CoCreate-app/CoCreate-socket-server/commit/3d102e18718cb3cda41471a12a437d4d9abad402))
|
|
33
|
+
|
|
1
34
|
## [1.31.1](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.31.0...v1.31.1) (2025-05-01)
|
|
2
35
|
|
|
3
36
|
|
package/README.md
CHANGED
|
@@ -1,65 +1,164 @@
|
|
|
1
|
-
# CoCreate
|
|
1
|
+
# CoCreate Socket Server
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A high-performance, multi-tenant WebSocket orchestration layer engineered for real-time collaboration, instant data synchronization, and ultra-low latency event streaming. This module serves as the primary gateway for end-user web applications interacting with the CoCreate clustered network.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-

|
|
7
|
-

|
|
8
|
-

|
|
5
|
+
---
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
## Documentation
|
|
11
8
|
|
|
12
|
-
[CoCreate
|
|
9
|
+
For complete API references, protocol event schemas, configuration guides, and examples, visit the **[CoCreate Socket Server Documentation](https://cocreatejs.com/docs/socket-server)**.
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
## Table of Contents
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
- [Documentation](#documentation)
|
|
14
|
+
- [The Real-Time Multiplexing Core](#the-real-time-multiplexing-core)
|
|
15
|
+
- [Why CoCreate Socket Server?](#why-cocreate-socket-server)
|
|
16
|
+
- [Multi-Tenant Rooms & Subscriptions](#multi-tenant-rooms--subscriptions)
|
|
17
|
+
- [The Connection Degradation Vector](#the-connection-degradation-vector)
|
|
18
|
+
- [Graceful Reconnection & State Recovery](#graceful-reconnection--state-recovery)
|
|
19
|
+
- [Configuration](#configuration)
|
|
20
|
+
- [Installation](#installation)
|
|
21
|
+
- [How to Contribute](#how-to-contribute)
|
|
22
|
+
- [License](#license)
|
|
17
23
|
|
|
18
|
-
|
|
24
|
+
---
|
|
19
25
|
|
|
20
|
-
-
|
|
21
|
-
- [Announcements](#announcements)
|
|
22
|
-
- [Roadmap](#roadmap)
|
|
23
|
-
- [How to Contribute](#how-to-contribute)
|
|
24
|
-
- [About](#about)
|
|
25
|
-
- [License](#license)
|
|
26
|
+
## The Real-Time Multiplexing Core
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
`@cocreate/socket-server` manages hundreds of thousands of concurrent persistent client connections with a zero-allocation, stream-oriented architecture.
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
### Native Binary Transport
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
To minimize serialization overhead and avoid high CPU usage, all real-time payloads can be encoded natively as binary streams using protocol buffers or compact JSON-in-MsgPack formats. This reduces network payload size by up to 60% compared to raw stringified JSON payloads.
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
### Organization & Room Isolation
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
Sockets are automatically classified upon connection based on authenticated organization context. Client connections can only subscribe to channels matching their tenant scopes, keeping data partitions strict and secure at the gateway edge.
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
$$
|
|
39
|
+
\text{Client Connection Request}
|
|
40
|
+
\xrightarrow{\text{JWT Authentication}}
|
|
41
|
+
\text{Isolated Tenant Context}
|
|
42
|
+
\implies
|
|
43
|
+
\begin{cases}
|
|
44
|
+
\text{Room 1} & \text{(Document Sync)} \\
|
|
45
|
+
\text{Room 2} & \text{(Presence Engine)}
|
|
46
|
+
\end{cases}
|
|
47
|
+
$$
|
|
38
48
|
|
|
39
|
-
|
|
49
|
+
```text
|
|
50
|
+
[Client App] ──► [WebSocket Connection] ──► [Socket Server Edge] ──► [Tenant Context Mapping]
|
|
51
|
+
│
|
|
52
|
+
▼
|
|
53
|
+
[Enforced Privacy]
|
|
54
|
+
```
|
|
40
55
|
|
|
41
|
-
|
|
56
|
+
---
|
|
42
57
|
|
|
43
|
-
|
|
58
|
+
## Why CoCreate Socket Server?
|
|
44
59
|
|
|
45
|
-
|
|
60
|
+
Standard real-time libraries (such as Socket.IO) introduce protocol wrapping overhead and maintain relatively heavy memory footprints per client, limiting total connection density on typical hardware.
|
|
46
61
|
|
|
47
|
-
|
|
62
|
+
`@cocreate/socket-server` is built on top of high-performance, low-level engine bindings, ensuring near-native socket operations. It tracks user presence, real-time collaboration, and administrative events with minimal overhead, allowing a single server instance to support tens of thousands of concurrent active connections.
|
|
48
63
|
|
|
49
|
-
|
|
64
|
+
---
|
|
50
65
|
|
|
51
|
-
|
|
66
|
+
## Multi-Tenant Rooms & Subscriptions
|
|
52
67
|
|
|
53
|
-
|
|
68
|
+
The socket server divides message distributions into isolated communication layers.
|
|
54
69
|
|
|
55
|
-
|
|
70
|
+
| Channel Scope | Delivery Mechanism | Common Use Case |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| **Organization Room** | Broadcast across tenant nodes | System announcements and configuration synchronization. |
|
|
73
|
+
| **Document Room** | Focused cluster routing | Real-time collaboration, cursor synchronization, and document updates. |
|
|
74
|
+
| **User Direct Channel** | Unicast targeted messaging | Personal notifications and account-specific events. |
|
|
75
|
+
| **Mesh Control Tunnel** | Internal inter-server communication | Administrative coordination and node draining. |
|
|
56
76
|
|
|
57
|
-
|
|
77
|
+
---
|
|
58
78
|
|
|
59
|
-
|
|
79
|
+
## The Connection Degradation Vector
|
|
80
|
+
|
|
81
|
+
To help `@cocreate/server-telemetry` evaluate worker saturation, the socket server continuously tracks local connection density ($D_c$).
|
|
82
|
+
|
|
83
|
+
$$
|
|
84
|
+
D_c =
|
|
85
|
+
\frac{\text{Active Sockets}}
|
|
86
|
+
{\text{Max Node Capacity}}
|
|
87
|
+
\cdot
|
|
88
|
+
\ln(\text{Messages Per Second}+1)
|
|
89
|
+
$$
|
|
90
|
+
|
|
91
|
+
As connection density approaches configured limits, the socket server notifies the surrounding infrastructure so new client connections can be routed toward healthier nodes.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Graceful Reconnection & State Recovery
|
|
96
|
+
|
|
97
|
+
Temporary network interruptions should not interrupt collaboration.
|
|
98
|
+
|
|
99
|
+
When a client disconnects unexpectedly, its session is placed into a short-lived recovery state. Outbound events are temporarily buffered in memory. If the client reconnects with its session identifier before the recovery window expires, pending events are replayed and synchronization continues without requiring the application to rebuild state.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Configuration
|
|
104
|
+
|
|
105
|
+
Create a `socket.config.json` file in your server root directory.
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"port": 8080,
|
|
110
|
+
"maxConnections": 50000,
|
|
111
|
+
"pingIntervalMs": 25000,
|
|
112
|
+
"pingTimeoutMs": 5000,
|
|
113
|
+
"maxPayloadBytes": 1048576,
|
|
114
|
+
"compression": {
|
|
115
|
+
"enabled": true,
|
|
116
|
+
"thresholdBytes": 1024
|
|
117
|
+
},
|
|
118
|
+
"security": {
|
|
119
|
+
"requireAuth": true,
|
|
120
|
+
"authTimeoutMs": 5000
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
60
126
|
|
|
61
|
-
|
|
127
|
+
## Installation
|
|
62
128
|
|
|
63
|
-
|
|
129
|
+
### npm
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm install @cocreate/socket-server
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Yarn
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
yarn add @cocreate/socket-server
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## How to Contribute
|
|
144
|
+
|
|
145
|
+
We encourage contributions to all CoCreate libraries. Please see our
|
|
146
|
+
[CONTRIBUTING.md](https://github.com/CoCreate-app/CoCreate-socket-server/blob/master/CONTRIBUTING.md)
|
|
147
|
+
guide for development workflows and contribution guidelines.
|
|
148
|
+
|
|
149
|
+
If you discover a bug or would like to request a feature, please open an issue on our
|
|
150
|
+
[GitHub Issues](https://github.com/CoCreate-app/CoCreate-socket-server/issues)
|
|
151
|
+
tracker.
|
|
152
|
+
|
|
153
|
+
For complete documentation, examples, and integration guides, visit:
|
|
154
|
+
|
|
155
|
+
https://cocreatejs.com/docs/socket-server
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
This software is dual-licensed under the GNU Affero General Public License version 3 (AGPLv3) and a commercial license.
|
|
64
162
|
|
|
65
|
-
|
|
163
|
+
- **Open Source Use:** For open-source projects and non-commercial use, this software is available under the AGPLv3. See the LICENSE file for the complete license text.
|
|
164
|
+
- **Commercial Use:** Commercial users must obtain a commercial license. Commercial licenses are available when signing up for an API key through the CoCreate platform.
|
package/denotest.json
ADDED
package/package.json
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/socket-server",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.33.1",
|
|
4
|
+
"description": "High-density multi-tenant WebSocket orchestration server for real-time state synchronization and cluster-mesh collaboration.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"collaborative-framework",
|
|
16
|
-
"realtime",
|
|
17
|
-
"realtime-framework",
|
|
18
|
-
"collaboration",
|
|
19
|
-
"shared-editing",
|
|
20
|
-
"html5-framework",
|
|
21
|
-
"javascript-framework"
|
|
6
|
+
"websocket-server",
|
|
7
|
+
"real-time-collaboration",
|
|
8
|
+
"multi-tenancy",
|
|
9
|
+
"state-synchronization",
|
|
10
|
+
"cluster-mesh",
|
|
11
|
+
"headless-cms",
|
|
12
|
+
"low-latency",
|
|
13
|
+
"p2p-replication",
|
|
14
|
+
"event-streaming"
|
|
22
15
|
],
|
|
23
16
|
"publishConfig": {
|
|
24
17
|
"access": "public"
|
|
25
18
|
},
|
|
26
|
-
"
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "./src/index.js",
|
|
27
21
|
"scripts": {
|
|
28
22
|
"demo": "PORT=5000 node demo/server.js",
|
|
29
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
30
|
-
"postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
|
|
23
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
31
24
|
},
|
|
32
25
|
"repository": {
|
|
33
26
|
"type": "git",
|
|
@@ -40,9 +33,8 @@
|
|
|
40
33
|
},
|
|
41
34
|
"homepage": "https://cocreate.app/docs/CoCreate-socket-server",
|
|
42
35
|
"dependencies": {
|
|
43
|
-
"@cocreate/config": "^1.13.
|
|
44
|
-
"@cocreate/utils": "^1.
|
|
45
|
-
"
|
|
46
|
-
"ws": "^7.5.10"
|
|
36
|
+
"@cocreate/config": "^1.13.4",
|
|
37
|
+
"@cocreate/utils": "^1.42.2",
|
|
38
|
+
"ws": "^8.21.1"
|
|
47
39
|
}
|
|
48
40
|
}
|
package/release.config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
dryRun: false,
|
|
3
|
-
branches: ["
|
|
3
|
+
branches: ["main"],
|
|
4
4
|
plugins: [
|
|
5
5
|
"@semantic-release/commit-analyzer",
|
|
6
6
|
"@semantic-release/release-notes-generator",
|
|
@@ -10,12 +10,20 @@ module.exports = {
|
|
|
10
10
|
changelogFile: "CHANGELOG.md",
|
|
11
11
|
},
|
|
12
12
|
],
|
|
13
|
-
"@semantic-release/npm",
|
|
14
|
-
"@semantic-release/github",
|
|
13
|
+
"@semantic-release/npm",
|
|
15
14
|
[
|
|
16
|
-
"@semantic-release/
|
|
15
|
+
"@semantic-release/github",
|
|
17
16
|
{
|
|
17
|
+
successComment: false,
|
|
18
|
+
failTitle: false,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
"@semantic-release/git",
|
|
23
|
+
{
|
|
24
|
+
// Only stage and commit the changelog and package.json
|
|
18
25
|
assets: ["CHANGELOG.md", "package.json"],
|
|
26
|
+
message: "chore(release): ${nextRelease.version} [skip ci]",
|
|
19
27
|
},
|
|
20
28
|
],
|
|
21
29
|
],
|