vani-meeting-client 2.3.0 → 2.3.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.
@@ -429,6 +429,7 @@ var MeetingHandler = /** @class */ (function () {
429
429
  };
430
430
  MeetingHandler.prototype.getUpdatedParticipantsListFromServer = function () {
431
431
  var _a;
432
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("getUpdatedParticipantsListFromServer", this.communicationHandler);
432
433
  (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.downloadParticipantsData();
433
434
  };
434
435
  MeetingHandler.prototype.getAllParticipants = function () {
@@ -17,6 +17,7 @@ export declare class CommunicationHandler {
17
17
  private meetingHandler?;
18
18
  private internetReachbilityTimeout?;
19
19
  private isReachable;
20
+ private isServerVerifiedIfStartMeetingCalled;
20
21
  constructor(meetingHandler: MeetingHandler);
21
22
  setMeetingStartRequest(_meetingStartRequest: MeetingStartRequest): void;
22
23
  setWebsocketCallHandler(_websocketCallHandler: WebsocketHandler): void;
@@ -57,7 +58,8 @@ export declare class CommunicationHandler {
57
58
  sendWebSocketMessage(type: WebSocketEvents, data: any): void;
58
59
  onVideoCallWebSocketMessage(websocketMessage: WebSocketMessageBody): Promise<void>;
59
60
  onReconnect(shouldInfromVideoCallHandler?: boolean): Promise<void>;
60
- onStartMeeingCalled(): boolean;
61
+ onStartMeeingCalled(isForceFully?: boolean): boolean;
62
+ checkIfStartMeetingUpdatedOnServer: () => Promise<void>;
61
63
  onAudioBlocked(data: any): void;
62
64
  onAudioUnblocked(data: any): void;
63
65
  onVideoBlocked(data: any): void;
@@ -67,6 +67,7 @@ var CommunicationHandler = /** @class */ (function () {
67
67
  this.allTracks = [];
68
68
  this.allSelfTracksForRestartSFU = undefined;
69
69
  this.isReachable = true;
70
+ this.isServerVerifiedIfStartMeetingCalled = false;
70
71
  this.refetchTrackForParticipant = function (participant) { return __awaiter(_this, void 0, void 0, function () {
71
72
  var _a;
72
73
  return __generator(this, function (_b) {
@@ -107,6 +108,29 @@ var CommunicationHandler = /** @class */ (function () {
107
108
  return [2 /*return*/];
108
109
  });
109
110
  }); };
111
+ this.checkIfStartMeetingUpdatedOnServer = function () { return __awaiter(_this, void 0, void 0, function () {
112
+ var _this = this;
113
+ var _a;
114
+ return __generator(this, function (_b) {
115
+ if (this.isServerVerifiedIfStartMeetingCalled) {
116
+ (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.init();
117
+ return [2 /*return*/];
118
+ }
119
+ this.downloadParticipantsData();
120
+ setTimeout(function () {
121
+ var _a;
122
+ if (_this.isServerVerifiedIfStartMeetingCalled) {
123
+ (_a = _this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.init();
124
+ return;
125
+ }
126
+ _this.onStartMeeingCalled(true);
127
+ _this.meetingStartRequest &&
128
+ _this.meetingStartRequest.logLevel === LogLevel.Debug &&
129
+ console.log("checkIfStartMeetingUpdatedOnServer", _this.isServerVerifiedIfStartMeetingCalled);
130
+ }, 1000);
131
+ return [2 /*return*/];
132
+ });
133
+ }); };
110
134
  //Connection Recheck
111
135
  this.destoryRoomForcefully = function () {
112
136
  var _a;
@@ -276,19 +300,25 @@ var CommunicationHandler = /** @class */ (function () {
276
300
  };
277
301
  CommunicationHandler.prototype.downloadParticipantsData = function () {
278
302
  var _a;
303
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("downloadParticipantsData");
279
304
  var obj = { type: WebSocketBasicEvents.GetAllParticipant, message: "" };
280
305
  (_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.sendSocketMessage(WebSocketBasicEvents.GetAllParticipant, obj);
281
306
  };
282
307
  CommunicationHandler.prototype.onServerParticipants = function (data) {
283
308
  var _this = this;
284
309
  var _a;
285
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log(data);
310
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("onServerParticipants", data);
286
311
  if (data && data.message) {
287
- var userIds = "";
312
+ // var userIds = "";
288
313
  Object.entries(data.message).forEach(function (_a) {
289
- var _b = __read(_a, 2), userId = _b[0], participant = _b[1];
290
- userIds = userIds + " " + userId;
314
+ var _b;
315
+ var _c = __read(_a, 2), userId = _c[0], participant = _c[1];
316
+ // userIds = userIds + " " + userId
291
317
  _this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("addParticipantIfNotExist from onServerParticipants", data);
318
+ var localParticipant = participant;
319
+ if (localParticipant && localParticipant.userId === ((_b = _this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId) && localParticipant.isStartMeetingCalled) {
320
+ _this.isServerVerifiedIfStartMeetingCalled = true;
321
+ }
292
322
  _this.addParticipantIfNotExist(participant, false);
293
323
  });
294
324
  // const allParticiapntsToBeRemove = this.allParticipants.filter(participant => (userIds.includes(participant.userId) === false))
@@ -327,8 +357,9 @@ var CommunicationHandler = /** @class */ (function () {
327
357
  this.emitMessageToSource(VaniEvent.OnParticipantDataUpdated, oldParticipant);
328
358
  }
329
359
  this.updateParticipantAudioVideoDataAccordingToTrack(oldParticipant);
360
+ (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onParticipantUpdated();
330
361
  try {
331
- if (oldParticipant.userId === ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId)) {
362
+ if (oldParticipant.userId === ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId)) {
332
363
  this.meetingStartRequest.userData = oldParticipant.userData;
333
364
  }
334
365
  }
@@ -340,18 +371,17 @@ var CommunicationHandler = /** @class */ (function () {
340
371
  participant = Object.assign(new Participant(participant.userId, participant.roomId, participant.userData, participant.isAdmin), participant);
341
372
  this.updateParticipantAudioVideoDataAccordingToTrack(participant);
342
373
  try {
343
- if (participant.userId === ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId)) {
374
+ if (participant.userId === ((_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId)) {
344
375
  this.meetingStartRequest.userData = participant.userData;
345
376
  }
346
377
  }
347
378
  catch (err) {
348
379
  }
349
380
  this.allParticipants.push(participant);
350
- (_c = this.videoCallHandler) === null || _c === void 0 ? void 0 : _c.onUserJoined(participant);
381
+ (_d = this.videoCallHandler) === null || _d === void 0 ? void 0 : _d.onUserJoined(participant);
351
382
  if (shouldInfrom) {
352
383
  this.emitMessageToSource(VaniEvent.OnUserJoined, participant);
353
384
  }
354
- (_d = this.videoCallHandler) === null || _d === void 0 ? void 0 : _d.onParticipantUpdated();
355
385
  return participant;
356
386
  }
357
387
  };
@@ -574,21 +604,24 @@ var CommunicationHandler = /** @class */ (function () {
574
604
  });
575
605
  });
576
606
  };
577
- CommunicationHandler.prototype.onStartMeeingCalled = function () {
607
+ CommunicationHandler.prototype.onStartMeeingCalled = function (isForceFully) {
578
608
  var _a, _b, _c, _d;
579
- if (this.isStartAndSetupWithServerCalled) {
609
+ if (isForceFully === void 0) { isForceFully = false; }
610
+ if (this.isStartAndSetupWithServerCalled && !isForceFully) {
580
611
  return;
581
612
  }
582
613
  if (!this.meetingStartRequest) {
583
- log.warn("meetingStartRequestObject not found onStartMeeingCalled");
614
+ log.warn("meetingStartRequestObject not found onStartMeeingCalled", isForceFully);
584
615
  return false;
585
616
  }
586
617
  if (!this.websocketCallHandler) {
587
- log.warn("Init method not called onStartMeeingCalled");
618
+ this.checkIfStartMeetingUpdatedOnServer();
619
+ log.warn("Init method not called onStartMeeingCalled", isForceFully);
588
620
  return false;
589
621
  }
590
622
  if (!this.websocketCallHandler.isWebScoketConnected()) {
591
- log.warn("WEB SOCKET NOT CONNECTED");
623
+ this.checkIfStartMeetingUpdatedOnServer();
624
+ log.warn("WEB SOCKET NOT CONNECTED", isForceFully);
592
625
  return false;
593
626
  }
594
627
  this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("webrtc onStartAndSetupWithServerCalled client");
@@ -601,6 +634,7 @@ var CommunicationHandler = /** @class */ (function () {
601
634
  selfParticpant.isStartMeetingCalled = true;
602
635
  }
603
636
  (_d = this.videoCallHandler) === null || _d === void 0 ? void 0 : _d.init();
637
+ this.checkIfStartMeetingUpdatedOnServer();
604
638
  };
605
639
  CommunicationHandler.prototype.onAudioBlocked = function (data) {
606
640
  var _a, _b, _c;
@@ -393,13 +393,13 @@ var UserMediaHandler = /** @class */ (function (_super) {
393
393
  }
394
394
  permissionApprovedFor = [];
395
395
  if (isForAudio && stream.getAudioTracks().length > 0) {
396
- this.onTrack(stream.getAudioTracks()[0], TrackKind.Audio, shouldAddTrackImmediately);
397
396
  // removeAndStreamInLocalStream(stream.getAudioTracks()[0])
398
397
  // updateLocalTrackInAllTracks(stream.getAudioTracks()[0]);
399
398
  this.communicationHandler.getSelfParticipant().isAudioEnable = true;
400
399
  data = { userId: (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId, type: "audio", status: "resume" };
401
400
  audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
402
401
  this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
402
+ this.onTrack(stream.getAudioTracks()[0], TrackKind.Audio, shouldAddTrackImmediately);
403
403
  if (this.muteUmutePromiseResolver) {
404
404
  this.muteUmutePromiseResolver({ message: "Success", error: 'NoError', isSuccess: true });
405
405
  this.muteUmutePromiseResolver = undefined;
@@ -415,13 +415,13 @@ var UserMediaHandler = /** @class */ (function (_super) {
415
415
  permissionApprovedFor.push(TrackKind.Audio);
416
416
  }
417
417
  if (isForVideo && stream.getVideoTracks().length > 0) {
418
- this.onTrack(stream.getVideoTracks()[0], TrackKind.Video, shouldAddTrackImmediately);
419
418
  // removeAndStreamInLocalStream(stream.getVideoTracks()[0])
420
419
  // updateLocalTrackInAllTracks(stream.getVideoTracks()[0])
421
420
  this.communicationHandler.getSelfParticipant().isVideoEnable = true;
422
421
  data = { userId: (_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId, type: "video", status: "resume" };
423
422
  audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
424
423
  this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
424
+ this.onTrack(stream.getVideoTracks()[0], TrackKind.Video, shouldAddTrackImmediately);
425
425
  if (this.videoPauseResumePromiseResolver) {
426
426
  this.videoPauseResumePromiseResolver({ message: "Success", error: 'NoError', isSuccess: true });
427
427
  this.videoPauseResumePromiseResolver = undefined;
@@ -807,11 +807,17 @@ var UserMediaHandler = /** @class */ (function (_super) {
807
807
  if (track && track.track) {
808
808
  track.track.enabled = false;
809
809
  if (streamKind === TrackKind.Audio) {
810
+ if (this.communicationHandler) {
811
+ this.communicationHandler.getSelfParticipant().isAudioEnable = false;
812
+ }
810
813
  var data = { userId: (_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId, type: "audio", status: "pause" };
811
814
  var audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
812
815
  this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
813
816
  }
814
817
  else {
818
+ if (this.communicationHandler) {
819
+ this.communicationHandler.getSelfParticipant().isVideoEnable = false;
820
+ }
815
821
  var data = { userId: (_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId, type: "video", status: "pause" };
816
822
  var audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
817
823
  this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
@@ -828,11 +834,17 @@ var UserMediaHandler = /** @class */ (function (_super) {
828
834
  if (track && track.track) {
829
835
  track.track.enabled = true;
830
836
  if (streamKind === TrackKind.Audio) {
837
+ if (this.communicationHandler) {
838
+ this.communicationHandler.getSelfParticipant().isAudioEnable = true;
839
+ }
831
840
  var data = { userId: (_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId, type: "audio", status: "resume" };
832
841
  var audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
833
842
  this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
834
843
  }
835
844
  else {
845
+ if (this.communicationHandler) {
846
+ this.communicationHandler.getSelfParticipant().isVideoEnable = true;
847
+ }
836
848
  var data = { userId: (_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId, type: "video", status: "resume" };
837
849
  var audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
838
850
  this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
@@ -730,7 +730,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
730
730
  };
731
731
  _this.isOfferInitParticipant = function (participant) {
732
732
  var selfParticpant = _this.communicationHandler.getSelfParticipant();
733
- if (participant.userId > selfParticpant.userId) {
733
+ if (participant.userId < selfParticpant.userId) {
734
734
  return true;
735
735
  }
736
736
  return false;
@@ -996,16 +996,22 @@ var WebrtcHandler = /** @class */ (function (_super) {
996
996
  return __awaiter(this, void 0, void 0, function () {
997
997
  var _this = this;
998
998
  return __generator(this, function (_b) {
999
- this.adaptationManager = new MediaAdaptationManager(function () { return _this.rtcPeerConnections.filter(Boolean); }, function () {
1000
- var _a, _b;
1001
- return (_b = (_a = _this.communicationHandler
1002
- .getAllSelfTracks()
1003
- .find(function (t) { var _a; return ((_a = t.track) === null || _a === void 0 ? void 0 : _a.kind) === 'video'; })) === null || _a === void 0 ? void 0 : _a.track) !== null && _b !== void 0 ? _b : null;
1004
- }, function (profile) {
1005
- _this.printLogIfRequired('Network profile', profile);
1006
- // Show UI banner: 'poor connection' / 'video paused' etc.
1007
- }, (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.deviceTier);
1008
- this.adaptationManager.start();
999
+ try {
1000
+ if (!this.adaptationManager) {
1001
+ this.adaptationManager = new MediaAdaptationManager(function () { return _this.rtcPeerConnections.filter(Boolean); }, function () {
1002
+ var _a, _b;
1003
+ return (_b = (_a = _this.communicationHandler
1004
+ .getAllSelfTracks()
1005
+ .find(function (t) { var _a; return ((_a = t.track) === null || _a === void 0 ? void 0 : _a.kind) === 'video'; })) === null || _a === void 0 ? void 0 : _a.track) !== null && _b !== void 0 ? _b : null;
1006
+ }, function (profile) {
1007
+ _this.printLogIfRequired('Network profile', profile);
1008
+ // Show UI banner: 'poor connection' / 'video paused' etc.
1009
+ }, (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.deviceTier);
1010
+ this.adaptationManager.start();
1011
+ }
1012
+ }
1013
+ catch (err) {
1014
+ }
1009
1015
  this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && this.printLogIfRequired(" Init", this.communicationHandler.getAllParticipants());
1010
1016
  this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && this.printLogIfRequired("Webrtc Init");
1011
1017
  this.communicationHandler.getAllParticipants().forEach(function (eachParticiapant) {
@@ -373,6 +373,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
373
373
  if (this.isWebScoketConnectedWithoutSetup()) {
374
374
  var paylod = { type: type, data: data };
375
375
  (_a = this.wss) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(paylod));
376
+ console.log("sendSocketMessage", type, data);
376
377
  }
377
378
  };
378
379
  WebsocketHandler.prototype.reconnectOnInternetFailur = function () {
@@ -590,7 +591,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
590
591
  return;
591
592
  }
592
593
  else {
593
- (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.emitMessageToSource(VaniEvent.OnConnected, {});
594
+ (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.emitMessageToSource(VaniEvent.OnSocketConnected, {});
594
595
  }
595
596
  }
596
597
  if (this.pingCheckTimeout) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",