@soundworks/core 4.0.0-alpha.25 → 4.0.0-alpha.27
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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/client/Socket.js +14 -21
- package/src/common/version.js +1 -1
- package/src/server/Sockets.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## v4.0.0-alpha.27 - 06/09/2025
|
|
2
|
+
|
|
3
|
+
- Fix: assign to `const`
|
|
4
|
+
|
|
5
|
+
## v4.0.0-alpha.26 - 05/09/2025
|
|
6
|
+
|
|
7
|
+
- Fix: improve reconnect strategy in case of socket connection failure
|
|
8
|
+
|
|
1
9
|
## v4.0.0-alpha.25 - 24/05/2025
|
|
2
10
|
|
|
3
11
|
- Fix: better default behavior for websocket connection URL
|
package/package.json
CHANGED
package/src/client/Socket.js
CHANGED
|
@@ -91,6 +91,8 @@ class Socket {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
webSocketOptions = {
|
|
94
|
+
// handshakeTimeout: 2000,
|
|
95
|
+
// do not reject self-signed certificates
|
|
94
96
|
rejectUnauthorized: false,
|
|
95
97
|
};
|
|
96
98
|
}
|
|
@@ -107,8 +109,6 @@ class Socket {
|
|
|
107
109
|
// Init socket
|
|
108
110
|
// ----------------------------------------------------------
|
|
109
111
|
return new Promise(resolve => {
|
|
110
|
-
let connectionRefusedLogged = false;
|
|
111
|
-
|
|
112
112
|
const trySocket = async () => {
|
|
113
113
|
const ws = new WebSocket(url, webSocketOptions);
|
|
114
114
|
|
|
@@ -118,7 +118,6 @@ class Socket {
|
|
|
118
118
|
|
|
119
119
|
this.#socket.addEventListener('message', e => {
|
|
120
120
|
if (e.data === PING_MESSAGE) {
|
|
121
|
-
// heartbeat();
|
|
122
121
|
this.#socket.send(PONG_MESSAGE);
|
|
123
122
|
// do not propagate ping / pong messages
|
|
124
123
|
return;
|
|
@@ -161,26 +160,20 @@ class Socket {
|
|
|
161
160
|
|
|
162
161
|
// cf. https://github.com/collective-soundworks/soundworks/issues/17
|
|
163
162
|
ws.addEventListener('error', e => {
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
163
|
+
if (ws.terminate) {
|
|
164
|
+
ws.terminate();
|
|
165
|
+
} else {
|
|
166
|
+
ws.close();
|
|
167
|
+
}
|
|
170
168
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (!connectionRefusedLogged) {
|
|
175
|
-
logger.log('[soundworks.Socket] Connection refused, waiting for the server to start');
|
|
176
|
-
// console.log(e.error);
|
|
177
|
-
connectionRefusedLogged = true;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// retry in 1 second
|
|
181
|
-
setTimeout(trySocket, 1000);
|
|
182
|
-
}
|
|
169
|
+
if (e.error) {
|
|
170
|
+
const msg = `[Socket Error] code: ${e.error.code}, message: ${e.error.message}`;
|
|
171
|
+
logger.log(msg);
|
|
183
172
|
}
|
|
173
|
+
|
|
174
|
+
// Try reconnect in all cases, note that if the socket has been connected the
|
|
175
|
+
// close event will be propagated and the launcher will restart the process.
|
|
176
|
+
setTimeout(trySocket, 1000);
|
|
184
177
|
});
|
|
185
178
|
};
|
|
186
179
|
|
package/src/common/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// [WARNING] This file is generated, do not edit
|
|
2
|
-
export default '4.0.0-alpha.
|
|
2
|
+
export default '4.0.0-alpha.27';
|
package/src/server/Sockets.js
CHANGED
|
@@ -173,7 +173,7 @@ class Sockets {
|
|
|
173
173
|
* JSON compatible data types (i.e. string, number, boolean, object, array and null).
|
|
174
174
|
*/
|
|
175
175
|
broadcast(roomIds, excludeSocket, channel, ...args) {
|
|
176
|
-
|
|
176
|
+
let targets = new Set();
|
|
177
177
|
|
|
178
178
|
if (typeof roomIds === 'string' || Array.isArray(roomIds)) {
|
|
179
179
|
if (typeof roomIds === 'string') {
|