@livedigital/client 3.7.0 → 3.7.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@livedigital/client",
3
3
  "author": "vlprojects",
4
4
  "license": "MIT",
5
- "version": "3.7.0",
5
+ "version": "3.7.1",
6
6
  "private": false,
7
7
  "bugs": {
8
8
  "url": "https://github.com/vlprojects/livedigital-sdk/issues"
@@ -110,6 +110,8 @@ class Engine {
110
110
 
111
111
  private rejoinRequested = false;
112
112
 
113
+ private isReleasing = false;
114
+
113
115
  private readonly handleChannelAudioObserverEvent: (data: string) => void;
114
116
 
115
117
  private readonly handleDataChannelEvent: (data: string) => void;
@@ -215,6 +217,12 @@ class Engine {
215
217
  }
216
218
 
217
219
  public async release(): Promise<void> {
220
+ if (this.isReleasing) {
221
+ return;
222
+ }
223
+
224
+ this.isReleasing = true;
225
+
218
226
  try {
219
227
  this.initialized = false;
220
228
  this.isJoined = false;
@@ -222,9 +230,6 @@ class Engine {
222
230
  this.channel = undefined;
223
231
  this.webRtcIssueDetector?.stopWatchingNewPeerConnections();
224
232
 
225
- this.network.reset();
226
- this.network.socket.disconnect();
227
-
228
233
  this.peersRepository.forEach((x) => x.reset());
229
234
  this.peersRepository.clear();
230
235
 
@@ -243,12 +248,17 @@ class Engine {
243
248
 
244
249
  this.removeClientEventEmitterListeners();
245
250
 
251
+ this.network.reset();
252
+ this.network.socket.disconnect();
253
+
246
254
  this.logger.debug('release()', {
247
255
  socketId: this.mySocketId,
248
256
  });
249
257
  } catch (error: unknown) {
250
258
  this.logger.error('release()', { error });
251
259
  throw new Error('Error release engine');
260
+ } finally {
261
+ this.isReleasing = false;
252
262
  }
253
263
  }
254
264
 
@@ -267,6 +277,10 @@ class Engine {
267
277
 
268
278
  private watchSocketState(): void {
269
279
  this.network.socket.observer.on(SocketIOEvents.State, (evt: SocketObserverEvent) => {
280
+ if (this.isReleasing) {
281
+ return;
282
+ }
283
+
270
284
  const { state, code, error } = evt;
271
285
  this.clientEventEmitter.emit(state, { code, error });
272
286