@reactoo/watchtogether-sdk-js 2.7.57 → 2.7.59

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.7.57",
3
+ "version": "2.7.59",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "dist/watchtogether-sdk.min.js",
6
6
  "module": "dist/watchtogether-sdk.min.js",
@@ -86,7 +86,7 @@ let room = function () {
86
86
  }
87
87
  }))
88
88
  },
89
-
89
+
90
90
  updateRoom: ({roomId, title, description, isPublic, isRouter, recordings, slug, password, maxParticipants, setInstanceType = false, wtChannelId, isHd, isStudioLayout, hasStudioChat, reduceRoomControls, chatRoomId, linkedRoomId, type, disableSync, defaultRegion, isSimulcast, videoCodec, customAttributes, dotAttribute} = {}) => {
91
91
  let _da = dotAttribute
92
92
  ? (Array.isArray(dotAttribute)
@@ -150,6 +150,19 @@ let room = function () {
150
150
  }))
151
151
  },
152
152
 
153
+ updateAttribute: ({roomId, id, operation, attributeName, value}) => {
154
+ return this.__privates.auth.__client
155
+ .then(client => client.apis.wt.updateAttribute({}, {
156
+ requestBody: {
157
+ id,
158
+ roomId,
159
+ operation,
160
+ attributeName,
161
+ value,
162
+ }
163
+ }))
164
+ },
165
+
153
166
  getInviteUrl: ({roomId, domain, url, autologin}) => {
154
167
  return this.__privates.auth.__client
155
168
  .then(client => client.apis.wt.invite({}, {
@@ -2,7 +2,7 @@ import { mqtt, iot } from 'aws-iot-device-sdk-v2';
2
2
  console.log('Worker: Starting up');
3
3
 
4
4
  let connection = null;
5
- let currentConnectionId = null;
5
+ let currentConnectionId = 1;
6
6
 
7
7
  self.onmessage = function(event) {
8
8
  const { type, params, topic, message } = event.data;
@@ -52,8 +52,8 @@ function connect(params) {
52
52
  const client = new mqtt.MqttClient();
53
53
 
54
54
  connection = client.new_connection(config);
55
- // generate random connection id
56
- currentConnectionId = Math.floor(Math.random() * 1000000);
55
+ // increment connection id
56
+ currentConnectionId++;
57
57
 
58
58
  setupConnectionListeners(currentConnectionId);
59
59
 
@@ -70,13 +70,23 @@ function connect(params) {
70
70
 
71
71
  function disconnect() {
72
72
  if (connection) {
73
+ const connectionId = currentConnectionId;
73
74
  connection.disconnect()
74
75
  .then(() => {
76
+ if(connectionId !== currentConnectionId) {
77
+ console.log('Worker: Connection Id mismatch, ignoring disconnect result', connectionId, currentConnectionId);
78
+ return;
79
+ }
75
80
  self.postMessage({ type: 'disconnect_result', data: {success: true} });
76
81
  })
77
82
  .catch((error) => {
83
+ if(connectionId !== currentConnectionId) {
84
+ console.log('Worker: Connection Id mismatch, ignoring disconnect result', connectionId, currentConnectionId);
85
+ return;
86
+ }
78
87
  self.postMessage({ type: 'disconnect_result', data: { success: false, error: error.message} });
79
88
  });
89
+ connection = null;
80
90
  } else {
81
91
  self.postMessage({ type: 'disconnect_result', data: {success: true} });
82
92
  }
@@ -126,7 +136,7 @@ function send(topic, message) {
126
136
  function setupConnectionListeners(connectionId) {
127
137
  connection.on('connect', () => {
128
138
  if(connectionId !== currentConnectionId) {
129
- console.log('Worker: Connection Id mismatch, ignoring connect event');
139
+ console.log('Worker: Connection Id mismatch, ignoring connect event', connectionId, currentConnectionId);
130
140
  return;
131
141
  }
132
142
  self.postMessage({ type: 'connect', connectionId: connectionId});
@@ -134,7 +144,7 @@ function setupConnectionListeners(connectionId) {
134
144
 
135
145
  connection.on('disconnect', () => {
136
146
  if(connectionId !== currentConnectionId) {
137
- console.log('Worker: Connection Id mismatch, ignoring disconnect event');
147
+ console.log('Worker: Connection Id mismatch, ignoring disconnect event', connectionId, currentConnectionId);
138
148
  return;
139
149
  }
140
150
  self.postMessage({ type: 'disconnect', connectionId: connectionId });
@@ -142,7 +152,7 @@ function setupConnectionListeners(connectionId) {
142
152
 
143
153
  connection.on('error', (error) => {
144
154
  if(connectionId !== currentConnectionId) {
145
- console.log('Worker: Connection Id mismatch, ignoring error event');
155
+ console.log('Worker: Connection Id mismatch, ignoring error event', connectionId, currentConnectionId);
146
156
  return;
147
157
  }
148
158
  self.postMessage({ type: 'error', data: error });
@@ -150,7 +160,7 @@ function setupConnectionListeners(connectionId) {
150
160
 
151
161
  connection.on('interrupt', (error) => {
152
162
  if(connectionId !== currentConnectionId) {
153
- console.log('Worker: Connection Id mismatch, ignoring interrupt event');
163
+ console.log('Worker: Connection Id mismatch, ignoring interrupt event', connectionId, currentConnectionId);
154
164
  return;
155
165
  }
156
166
  self.postMessage({ type: 'interrupt', data: error, connectionId: connectionId });
@@ -158,7 +168,7 @@ function setupConnectionListeners(connectionId) {
158
168
 
159
169
  connection.on('resume', (error) => {
160
170
  if(connectionId !== currentConnectionId) {
161
- console.log('Worker: Connection Id mismatch, ignoring resume event');
171
+ console.log('Worker: Connection Id mismatch, ignoring resume event', connectionId, currentConnectionId);
162
172
  return;
163
173
  }
164
174
  self.postMessage({ type: 'resume', data: error, connectionId: connectionId });
@@ -166,7 +176,7 @@ function setupConnectionListeners(connectionId) {
166
176
 
167
177
  connection.on('message', (topic, payload) => {
168
178
  if(connectionId !== currentConnectionId) {
169
- console.log('Worker: Connection Id mismatch, ignoring message event');
179
+ console.log('Worker: Connection Id mismatch, ignoring message event', connectionId, currentConnectionId);
170
180
  return;
171
181
  }
172
182
  self.postMessage({ type: 'message', data: { topic, payload }, connectionId: connectionId });
@@ -174,7 +184,7 @@ function setupConnectionListeners(connectionId) {
174
184
 
175
185
  connection.on('connection_success', (error) => {
176
186
  if(connectionId !== currentConnectionId) {
177
- console.log('Worker: Connection Id mismatch, ignoring connection_success event');
187
+ console.log('Worker: Connection Id mismatch, ignoring connection_success event', connectionId, currentConnectionId);
178
188
  return;
179
189
  }
180
190
  self.postMessage({ type: 'connection_success', data: error, connectionId: connectionId });
@@ -182,7 +192,7 @@ function setupConnectionListeners(connectionId) {
182
192
 
183
193
  connection.on('connection_failure', (error) => {
184
194
  if(connectionId !== currentConnectionId) {
185
- console.log('Worker: Connection Id mismatch, ignoring connection_failure event');
195
+ console.log('Worker: Connection Id mismatch, ignoring connection_failure event', connectionId, currentConnectionId);
186
196
  return;
187
197
  }
188
198
  self.postMessage({ type: 'connection_failure', data: error, connectionId: connectionId });