@reactoo/watchtogether-sdk-js 2.5.30 → 2.5.35

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.
@@ -32,7 +32,6 @@
32
32
  <input type="number" id="connection-timeout" placeholder="5000" min="0">
33
33
 
34
34
  <br><br>
35
-
36
35
  <button type="submit" id="join-room">Create users and join room</button>
37
36
 
38
37
  <button type="button" id="leave-room" onclick="leaveParticipants()">Leave room</button>
@@ -52,7 +51,7 @@
52
51
 
53
52
  let participantsCount = 3;
54
53
  let instanceType = "reactooDemo";
55
- let roomId = "0512f218-6a4a-45e1-9d05-d5a0e5afb33d";
54
+ let roomId = "2e705d79-aaa9-4790-a3d7-512858f60932";
56
55
  let pinHash = undefined;
57
56
  let timeoutBetweenParticipantsJoins = 5000;
58
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.5.30",
3
+ "version": "2.5.35",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -31,6 +31,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
31
31
 
32
32
  const emitter = _emitter_();
33
33
  let alpTimeoutId = null;
34
+ let abortController = null;
34
35
  let ___; // return object
35
36
 
36
37
  room.on('addLocalParticipant', () => {
@@ -86,13 +87,14 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
86
87
  connect: function ({reactooRoomId = null} = {}) {
87
88
  emitter.emit('connecting', true);
88
89
  clearTimeout(alpTimeoutId);
90
+ abortController = new AbortController();
89
91
  return Promise.all([wt.room.__joinRoom({
90
92
  roomId: reactooRoomId || primaryRoomId,
91
93
  pinHash,
92
94
  isTalkback,
93
95
  isMonitor,
94
96
  isInstructor
95
- }), wt.user.getUserSelf()])
97
+ }, abortController?.signal), wt.user.getUserSelf()])
96
98
  .then(([roomData, userData]) => {
97
99
  // Happens when we reroute user to a different room
98
100
  if(roomData?.data?.reactooRoomId !== roomId) {
@@ -111,6 +113,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
111
113
 
112
114
  disconnect: function (dontWaitForResponses) {
113
115
  clearTimeout(alpTimeoutId);
116
+ abortController?.abort?.();
114
117
  return room.disconnect(dontWaitForResponses);
115
118
  },
116
119
 
@@ -120,7 +123,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
120
123
  emitter.emit('reconnecting', true);
121
124
  room.isRestarting = true;
122
125
 
123
- let wasPublished = room._isPublished;
126
+ let wasPublished = room.isPublished;
124
127
  let handle = room._getHandle(room.handleId);
125
128
  let stream = null;
126
129
  if (handle?.webrtcStuff?.stream && wasPublished) {
@@ -287,7 +290,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
287
290
  },
288
291
 
289
292
  setRoomVars: () => {
290
- return wt.room.getRoomById(roomId, pinHash)
293
+ return wt.room.getRoomById(roomId, pinHash, undefined, false, abortController?.signal)
291
294
  .then(r => {
292
295
  // setting observers userId's so we can ignore them when creating participant
293
296
  room.setObserverIds(r.data.allowedObservers);
@@ -178,10 +178,16 @@ let room = function () {
178
178
  .then(client => client.apis.wt.setUser({messageId, userId, roomId, flag, timestamp, option}));
179
179
  },
180
180
 
181
- getRoomById: (id, pinHash = undefined, showPublic = undefined, demo = false) => {
181
+ getRoomById: (id, pinHash = undefined, showPublic = undefined, demo = false, signal) => {
182
182
  return this.__privates.auth.__client
183
- .then(client => client.apis.wt.getRoom({id, pinHash, "public": showPublic, demo}))
184
-
183
+ .then(client => client.apis.wt.getRoom({id, pinHash, "public": showPublic, demo}, {
184
+ ...(signal ? {
185
+ requestInterceptor: (req) => {
186
+ req.signal = signal;
187
+ return req;
188
+ }
189
+ } : {}),
190
+ }))
185
191
  },
186
192
 
187
193
  getRoomBySlug: (slug, password = undefined, showPublic = undefined, demo = false) => {
@@ -199,7 +205,7 @@ let room = function () {
199
205
  }))
200
206
  },
201
207
 
202
- __joinRoom: ({roomId, pinHash, instanceType = this.__instanceType, isTalkback = undefined, isMonitor = undefined, isInstructor = undefined, customBearer = undefined} = {}) => {
208
+ __joinRoom: ({roomId, pinHash, instanceType = this.__instanceType, isTalkback = undefined, isMonitor = undefined, isInstructor = undefined, customBearer = undefined} = {}, signal) => {
203
209
  return this.__privates.auth.__client
204
210
  .then(client => client.apis.wt.join({
205
211
  roomId,
@@ -210,15 +216,12 @@ let room = function () {
210
216
  isInstructor,
211
217
  platform: this.browser === 'firefox' ? 'web-firefox' : 'web'
212
218
  }, {
213
- ...(customBearer ? {
219
+ ...(signal ? {
214
220
  requestInterceptor: (req) => {
215
- if (!req.headers) {
216
- req.headers = {};
217
- }
218
- req.headers['Authorization'] = customBearer;
221
+ req.signal = signal;
219
222
  return req;
220
223
  }
221
- } : {})
224
+ } : {}),
222
225
  }))
223
226
  },
224
227
 
@@ -196,7 +196,7 @@ const syncVodDashJs = function ({room, wt, roomSession, emitter} = {}) {
196
196
  };
197
197
 
198
198
  const isConnected = () => {
199
- return room._isDataChannelOpen && room._hasJoined;
199
+ return room._isDataChannelOpen && room.isConnected;
200
200
  };
201
201
 
202
202
  const buffering = (event) => {
@@ -178,7 +178,7 @@ const syncDashJs = function ({room, wt, roomSession, emitter} = {}) {
178
178
  };
179
179
 
180
180
  const isConnected = () => {
181
- return room._isDataChannelOpen && room._hasJoined;
181
+ return room._isDataChannelOpen && room.isConnected;
182
182
  };
183
183
 
184
184
  const buffering = (event) => {
@@ -178,7 +178,7 @@ const syncDaznDash = function ({room, wt, roomSession, emitter} = {}) {
178
178
  };
179
179
 
180
180
  const isConnected = () => {
181
- return room._isDataChannelOpen && room._hasJoined;
181
+ return room._isDataChannelOpen && room.isConnected;
182
182
  };
183
183
 
184
184
  const parseDataEvents = (msg = {}) => {
@@ -178,7 +178,7 @@ const syncDoris = function ({room, wt, roomSession, emitter} = {}) {
178
178
  };
179
179
 
180
180
  const isConnected = () => {
181
- return room._isDataChannelOpen && room._hasJoined;
181
+ return room._isDataChannelOpen && room.isConnected;
182
182
  };
183
183
 
184
184
  const parseDataEvents = (msg = {}) => {
@@ -198,7 +198,7 @@ const syncVodHlsJs = function ({room, wt, roomSession, emitter} = {}) {
198
198
  };
199
199
 
200
200
  const isConnected = () => {
201
- return room._isDataChannelOpen && room._hasJoined;
201
+ return room._isDataChannelOpen && room.isConnected;
202
202
  };
203
203
 
204
204
  const buffering = (event, data = {}) => {
@@ -197,7 +197,7 @@ const syncHlsJs = function ({room, wt, roomSession, emitter} = {}) {
197
197
  };
198
198
 
199
199
  const isConnected = () => {
200
- return room._isDataChannelOpen && room._hasJoined;
200
+ return room._isDataChannelOpen && room.isConnected;
201
201
  };
202
202
 
203
203
  const buffering = (event, data = {}) => {
@@ -196,7 +196,7 @@ const syncVodHlsJs = function ({room, wt, roomSession, emitter} = {}) {
196
196
  };
197
197
 
198
198
  const isConnected = () => {
199
- return room._isDataChannelOpen && room._hasJoined;
199
+ return room._isDataChannelOpen && room.isConnected;
200
200
  };
201
201
 
202
202
  const executePlayerIotEvents = (data) => {
@@ -178,7 +178,7 @@ const syncNativeHls = function ({room, wt, roomSession, emitter} = {}) {
178
178
  };
179
179
 
180
180
  const isConnected = () => {
181
- return room._isDataChannelOpen && room._hasJoined;
181
+ return room._isDataChannelOpen && room.isConnected;
182
182
  };
183
183
 
184
184
  const parseDataEvents = (msg = {}) => {
@@ -196,7 +196,7 @@ const syncVodShakaDash = function ({room, wt, roomSession, emitter} = {}) {
196
196
  };
197
197
 
198
198
  const isConnected = () => {
199
- return room._isDataChannelOpen && room._hasJoined;
199
+ return room._isDataChannelOpen && room.isConnected;
200
200
  };
201
201
 
202
202
  const buffering = (event) => {
@@ -184,7 +184,7 @@ const syncDaznDash = function ({room, wt, roomSession, emitter} = {}) {
184
184
  };
185
185
 
186
186
  const isConnected = () => {
187
- return room._isDataChannelOpen && room._hasJoined;
187
+ return room._isDataChannelOpen && room.isConnected;
188
188
  };
189
189
 
190
190
  const parseDataEvents = (msg = {}) => {
@@ -181,7 +181,7 @@ const syncUniversal = function ({room, wt, roomSession, emitter} = {}) {
181
181
  };
182
182
 
183
183
  const isConnected = () => {
184
- return room._isDataChannelOpen && room._hasJoined;
184
+ return room._isDataChannelOpen && room.isConnected;
185
185
  };
186
186
 
187
187
  const parseDataEvents = (msg = {}) => {