@soundworks/core 3.4.0 → 3.5.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/client/Socket.js +7 -1
- package/package.json +1 -1
- package/server/Server.js +6 -2
- package/server/utils/logger.js +34 -0
package/client/Socket.js
CHANGED
|
@@ -119,6 +119,8 @@ class Socket {
|
|
|
119
119
|
|
|
120
120
|
const stringSocketUrl = `${url}?binary=0&${queryParams}`;
|
|
121
121
|
await new Promise((resolve, reject) => {
|
|
122
|
+
let connectionRefusedLogged = false;
|
|
123
|
+
|
|
122
124
|
const trySocket = async () => {
|
|
123
125
|
log(`[string socket] trying connection - url: ${stringSocketUrl}`);
|
|
124
126
|
const ws = new _isomorphicWs.default(stringSocketUrl, webSocketOptions);
|
|
@@ -145,7 +147,11 @@ class Socket {
|
|
|
145
147
|
|
|
146
148
|
ws.addEventListener('error', e => {
|
|
147
149
|
if (e.type === 'error' && e.error.code === 'ECONNREFUSED') {
|
|
148
|
-
|
|
150
|
+
if (!connectionRefusedLogged) {
|
|
151
|
+
console.log('[socket] connection refused, waiting for the server to start');
|
|
152
|
+
connectionRefusedLogged = true;
|
|
153
|
+
}
|
|
154
|
+
|
|
149
155
|
setTimeout(trySocket, 1000);
|
|
150
156
|
}
|
|
151
157
|
});
|
package/package.json
CHANGED
package/server/Server.js
CHANGED
|
@@ -238,13 +238,16 @@ class Server {
|
|
|
238
238
|
pingInterval: 5000
|
|
239
239
|
},
|
|
240
240
|
useHttps: false,
|
|
241
|
-
crossOriginIsolated: true
|
|
241
|
+
crossOriginIsolated: true,
|
|
242
|
+
verbose: true
|
|
242
243
|
},
|
|
243
244
|
app: {
|
|
244
245
|
name: 'soundworks'
|
|
245
246
|
}
|
|
246
247
|
};
|
|
247
|
-
this.config = (0, _lodash.default)({}, defaultConfig, config);
|
|
248
|
+
this.config = (0, _lodash.default)({}, defaultConfig, config);
|
|
249
|
+
|
|
250
|
+
_logger.default.configure(this.config.env.verbose); // @note: do not remove
|
|
248
251
|
// backward compatibility w/ assetsDomain and `soundworks-template`
|
|
249
252
|
// cf. https://github.com/collective-soundworks/soundworks/issues/35
|
|
250
253
|
// see also '@soundworks/plugin-audio-buffer-loader' (could be updated more
|
|
@@ -255,6 +258,7 @@ class Server {
|
|
|
255
258
|
// + new template
|
|
256
259
|
// @note: keep `websocket.path` as defined should be enough
|
|
257
260
|
|
|
261
|
+
|
|
258
262
|
if (!this.config.env.assetsDomain && this.config.env.subpath !== undefined) {
|
|
259
263
|
const subpath = this.config.env.subpath.replace(/^\//, '').replace(/\/$/, '');
|
|
260
264
|
|
package/server/utils/logger.js
CHANGED
|
@@ -15,11 +15,25 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
15
|
* @private
|
|
16
16
|
*/
|
|
17
17
|
const logger = {
|
|
18
|
+
verbose: true,
|
|
19
|
+
|
|
20
|
+
configure(verbose) {
|
|
21
|
+
this.verbose = verbose;
|
|
22
|
+
},
|
|
23
|
+
|
|
18
24
|
title(msg) {
|
|
25
|
+
if (!this.verbose) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
console.log(_chalk.default.cyan(`+ ${msg}`));
|
|
20
30
|
},
|
|
21
31
|
|
|
22
32
|
clientConfigAndRouting(routes, config) {
|
|
33
|
+
if (!this.verbose) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
const clientsConfig = config.app.clients;
|
|
24
38
|
const serverIp = config.env.serverIp;
|
|
25
39
|
const auth = config.env.auth;
|
|
@@ -76,22 +90,42 @@ const logger = {
|
|
|
76
90
|
},
|
|
77
91
|
|
|
78
92
|
ip(protocol, address, port) {
|
|
93
|
+
if (!this.verbose) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
79
97
|
console.log(` ${protocol}://${address}:${_chalk.default.green(port)}`);
|
|
80
98
|
},
|
|
81
99
|
|
|
82
100
|
pluginStart(name) {
|
|
101
|
+
if (!this.verbose) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
83
105
|
console.log(` ${name} ${_chalk.default.yellow('start...')}`);
|
|
84
106
|
},
|
|
85
107
|
|
|
86
108
|
pluginStarted(name) {
|
|
109
|
+
if (!this.verbose) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
87
113
|
console.log(` ${name} ${_chalk.default.cyan('started')}`);
|
|
88
114
|
},
|
|
89
115
|
|
|
90
116
|
pluginReady(name) {
|
|
117
|
+
if (!this.verbose) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
91
121
|
console.log(` ${name} ${_chalk.default.green('ready')}`);
|
|
92
122
|
},
|
|
93
123
|
|
|
94
124
|
pluginErrored(name) {
|
|
125
|
+
if (!this.verbose) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
95
129
|
console.log(` ${name} ${_chalk.default.red('errors')}`);
|
|
96
130
|
}
|
|
97
131
|
|