@soundworks/core 3.2.0 → 3.2.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 CHANGED
@@ -91,6 +91,7 @@ class Socket {
91
91
  }
92
92
 
93
93
  let url;
94
+ let webSocketOptions;
94
95
 
95
96
  if (isBrowser()) {
96
97
  const protocol = window.location.protocol.replace(/^http?/, 'ws');
@@ -99,13 +100,17 @@ class Socket {
99
100
  port
100
101
  } = window.location;
101
102
  url = `${protocol}//${hostname}:${port}/${path}`;
103
+ webSocketOptions = {};
102
104
  } else {
103
- const protocol = config.useHttps ? 'wss:' : 'ws:';
105
+ const protocol = config.env.useHttps ? 'wss:' : 'ws:';
104
106
  const {
105
107
  serverIp,
106
108
  port
107
109
  } = config.env;
108
110
  url = `${protocol}//${serverIp}:${port}/${path}`;
111
+ webSocketOptions = {
112
+ rejectUnauthorized: false
113
+ };
109
114
  }
110
115
 
111
116
  const queryParams = `clientType=${clientType}&key=${key}`; // ----------------------------------------------------------
@@ -116,7 +121,7 @@ class Socket {
116
121
  await new Promise((resolve, reject) => {
117
122
  const trySocket = async () => {
118
123
  log(`[string socket] trying connection - url: ${stringSocketUrl}`);
119
- const ws = new _isomorphicWs.default(stringSocketUrl);
124
+ const ws = new _isomorphicWs.default(stringSocketUrl, webSocketOptions);
120
125
  ws.addEventListener('open', connectEvent => {
121
126
  // parse incoming messages for pubsub
122
127
  this.ws = ws;
@@ -154,7 +159,7 @@ class Socket {
154
159
  const binarySocketUrl = `${url}?binary=1&${queryParams}`;
155
160
  await new Promise((resolve, reject) => {
156
161
  log(`[binary socket] trying connection - url: ${binarySocketUrl}`);
157
- const ws = new _isomorphicWs.default(binarySocketUrl);
162
+ const ws = new _isomorphicWs.default(binarySocketUrl, webSocketOptions);
158
163
  ws.binaryType = 'arraybuffer';
159
164
  ws.addEventListener('open', connectEvent => {
160
165
  // parse incoming messages for pubsub
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soundworks/core",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "full-stack javascript framework for distributed audio visual experiences on the web",
5
5
  "authors": [
6
6
  "Benjamin Matuszewski",
package/server/Server.js CHANGED
@@ -310,6 +310,8 @@ class Server {
310
310
  // ------------------------------------------------------------
311
311
  // init acitvities
312
312
  // ------------------------------------------------------------
313
+ // we should at least have one activity registered for each client here
314
+ // i.e. the Experience so it's ok
313
315
  this.activities.forEach(activity => {
314
316
  activity.clientTypes.forEach(clientType => {
315
317
  if (!this._clientTypeActivitiesMap[clientType]) {
@@ -572,6 +574,11 @@ class Server {
572
574
  _onSocketConnection(clientType, socket) {
573
575
  const client = new _Client.default(clientType, socket);
574
576
  const activities = this._clientTypeActivitiesMap[clientType];
577
+
578
+ if (activities == undefined) {
579
+ throw new Error(`No activity registered for "${clientType}" clients, make sure an Experience has been initialized for this client (see src/server/index.js)`);
580
+ }
581
+
575
582
  socket.addListener('close', () => {
576
583
  // clean sockets
577
584
  socket.terminate(); // remove client from activities