podchat-browser 11.4.3 → 12.1.0

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.
@@ -56318,6 +56318,7 @@ WildEmitter.mixin(WildEmitter);
56318
56318
  TERMINATE_CALL: 96,
56319
56319
  MUTE_CALL_PARTICIPANT: 97,
56320
56320
  UNMUTE_CALL_PARTICIPANT: 98,
56321
+ CANCEL_GROUP_CALL: 99, //TODO: not implemented
56321
56322
  LOGOUT: 100,
56322
56323
  LOCATION_PING: 101,
56323
56324
  CLOSE_THREAD: 102,
@@ -56400,8 +56401,13 @@ WildEmitter.mixin(WildEmitter);
56400
56401
  : 180,
56401
56402
  currentCallParams = {},
56402
56403
  currentCallId = null,
56404
+ newCallId = null,
56403
56405
  shouldReconnectCallTimeout = null,
56404
56406
  callTopics = {},
56407
+ callMetaDataTypes = {
56408
+ POORCONNECTION: 1,
56409
+ POORCONNECTIONRESOLVED: 2
56410
+ },
56405
56411
  screenShareState = {
56406
56412
  started: false,
56407
56413
  imOwner: false
@@ -56699,172 +56705,29 @@ WildEmitter.mixin(WildEmitter);
56699
56705
  */
56700
56706
  startCallWebRTCFunctions = function (params, callback) {
56701
56707
  if (callDivId) {
56702
- var callParentDiv,
56703
- callVideo = (typeof params.video === 'boolean') ? params.video : true,
56708
+ var callVideo = (typeof params.video === 'boolean') ? params.video : true,
56704
56709
  callMute = (typeof params.mute === 'boolean') ? params.mute : false;
56705
- //sendingTopic = params.sendingTopic,
56706
- //receiveTopic = params.receiveTopic;
56710
+
56711
+ if(params.selfData) {
56712
+ callStateController.setupCallParticipant(params.selfData);
56713
+ }
56707
56714
 
56708
56715
  if(params.clientsList && params.clientsList.length) {
56709
56716
  for(var i in params.clientsList) {
56710
- callStateController.setupCallParticipant(params.clientsList[i]);
56711
- //callStateController.callUsers.push(params.clientsList[i]);
56717
+ if(params.clientsList[i].userId !== chatMessaging.userInfo.id)
56718
+ callStateController.setupCallParticipant(params.clientsList[i]);
56712
56719
  }
56713
56720
  }
56714
56721
 
56715
56722
  callStateController.setupScreenSharingObject(params.screenShare);
56716
56723
 
56717
- /*callTopics['sendVideoTopic'] = 'Vi-' + sendingTopic;
56718
- callTopics['sendAudioTopic'] = 'Vo-' + sendingTopic;
56719
- callTopics['screenShare'] = params.screenShare;
56720
- //callTopics['receiveVideoTopic'] = 'Vi-' + receiveTopic;
56721
- //callTopics['receiveAudioTopic'] = 'Vo-' + receiveTopic;
56722
- callTopics['receive'] = [];
56723
- callTopics['receive'].push({
56724
- "VideoTopic": 'Vi-' + receiveTopic,
56725
- "AudioTopic": 'Vo-' + receiveTopic
56726
- });*/
56727
-
56728
- /*webpeersMetadata[callTopics['sendVideoTopic']] = {
56729
- interval: null,
56730
- receivedSdpAnswer: false,
56731
- connectionQualityInterval: null,
56732
- poorConnectionCount: 0,
56733
- poorConnectionResolvedCount: 0,
56734
- isConnectionPoor: false
56735
- };
56736
- webpeersMetadata[callTopics['sendAudioTopic']] = {
56737
- interval: null,
56738
- receivedSdpAnswer: false,
56739
- connectionQualityInterval: null,
56740
- poorConnectionCount: 0,
56741
- poorConnectionResolvedCount: 0,
56742
- isConnectionPoor: false
56743
- };
56744
- webpeersMetadata[callTopics['screenShare']] = {
56745
- interval: null,
56746
- receivedSdpAnswer: false,
56747
- connectionQualityInterval: null,
56748
- poorConnectionCount: 0,
56749
- poorConnectionResolvedCount: 0,
56750
- isConnectionPoor: false
56751
- };
56752
-
56753
- for(var i in callTopics['receive']) {
56754
- webpeersMetadata[callTopics['receive'][i]['VideoTopic']] = {
56755
- interval: null,
56756
- receivedSdpAnswer: false
56757
- };
56758
- webpeersMetadata[callTopics['receive'][i]['AudioTopic']] = {
56759
- interval: null,
56760
- receivedSdpAnswer: false
56761
- };
56762
- }*/
56763
-
56764
- //callParentDiv = document.getElementById(callDivId);
56765
-
56766
- /*// Local Video Tag
56767
- if (callVideo && !uiRemoteMedias[callTopics['sendVideoTopic']]) {
56768
- uiRemoteMedias[callTopics['sendVideoTopic']] = document.createElement('video');
56769
- var el = uiRemoteMedias[callTopics['sendVideoTopic']];
56770
- el.setAttribute('id', 'uiRemoteVideo-' + callTopics['sendVideoTopic']);
56771
- el.setAttribute('class', callVideoTagClassName);
56772
- el.setAttribute('playsinline', '');
56773
- el.setAttribute('muted', '');
56774
- el.setAttribute('width', callVideoMinWidth + 'px');
56775
- el.setAttribute('height', callVideoMinHeight + 'px');
56776
- }
56777
-
56778
- // Local Audio Tag
56779
- if (!uiRemoteMedias[callTopics['sendAudioTopic']]) {
56780
- uiRemoteMedias[callTopics['sendAudioTopic']] = document.createElement('audio');
56781
- var el = uiRemoteMedias[callTopics['sendAudioTopic']];
56782
- el.setAttribute('id', 'uiRemoteAudio-' + callTopics['sendAudioTopic']);
56783
- el.setAttribute('class', callAudioTagClassName);
56784
- el.setAttribute('autoplay', '');
56785
- el.setAttribute('muted', '');
56786
- el.setAttribute('controls', '');
56787
- }
56788
-
56789
- for(var i in callTopics['receive']){
56790
- // Remote Video Tag
56791
- if (callVideo && !uiRemoteMedias[callTopics['receive'][i]['VideoTopic']]) {
56792
- uiRemoteMedias[callTopics['receive'][i]['VideoTopic']] = document.createElement('video');
56793
- var el = uiRemoteMedias[callTopics['receive'][i]['VideoTopic']];
56794
- el.setAttribute('id', 'uiRemoteVideo-' + callTopics['receive'][i]['VideoTopic']);
56795
- el.setAttribute('class', callVideoTagClassName);
56796
- el.setAttribute('playsinline', '');
56797
- el.setAttribute('muted', '');
56798
- el.setAttribute('width', callVideoMinWidth + 'px');
56799
- el.setAttribute('height', callVideoMinHeight + 'px');
56800
- }
56801
-
56802
- // Remote Audio Tag
56803
- if (!uiRemoteMedias[callTopics['receive'][i]['AudioTopic']]) {
56804
- uiRemoteMedias[callTopics['receive'][i]['AudioTopic']] = document.createElement('audio');
56805
- var el = uiRemoteMedias[callTopics['receive'][i]['AudioTopic']];
56806
- el.setAttribute('id', 'uiRemoteAudio-' + callTopics['receive'][i]['AudioTopic']);
56807
- el.setAttribute('class', callAudioTagClassName);
56808
- el.setAttribute('autoplay', '');
56809
- callMute && el.setAttribute('muted', '');
56810
- el.setAttribute('controls', '');
56811
- }
56812
- }*/
56813
-
56814
56724
  callback && callback(generateCallUIList());
56815
56725
 
56816
- /*for(var i in callTopics['receive']) {
56817
- uiRemoteElements.push(uiRemoteMedias[callTopics['receive'][i]['AudioTopic']])
56818
- callVideo && uiRemoteElements.push(uiRemoteMedias[callTopics['receive'][i]['VideoTopic']])
56819
- }
56820
-
56821
- if (callParentDiv) {
56822
- callVideo && callParentDiv.appendChild(uiRemoteMedias[callTopics['sendVideoTopic']]);
56823
- callParentDiv.appendChild(uiRemoteMedias[callTopics['sendAudioTopic']]);
56824
- if(callVideo) {
56825
- for(var i in callTopics['receive']) {
56826
- callParentDiv.appendChild(uiRemoteMedias[callTopics['receive'][i]['VideoTopic']])
56827
- }
56828
- }
56829
- for(var i in callTopics['receive']) {
56830
- callParentDiv.appendChild(uiRemoteMedias[callTopics['receive'][i]['AudioTopic']]);
56831
- }
56832
-
56833
- callback && callback({
56834
- 'uiLocalVideo': uiRemoteMedias[callTopics['sendVideoTopic']],
56835
- 'uiLocalAudio': uiRemoteMedias[callTopics['sendAudioTopic']],
56836
- uiRemoteElements: uiRemoteElements
56837
- /!* 'uiRemoteVideo': uiRemoteMedias[callTopics['receiveVideoTopic']],
56838
- 'uiRemoteAudio': uiRemoteMedias[callTopics['receiveAudioTopic']]*!/
56839
- });
56840
- } else {
56841
- callback && callback({
56842
- 'uiLocalVideo': uiRemoteMedias[callTopics['sendVideoTopic']],
56843
- 'uiLocalAudio': uiRemoteMedias[callTopics['sendAudioTopic']],
56844
- uiRemoteElements: uiRemoteElements
56845
- /!*'uiRemoteVideo': uiRemoteMedias[callTopics['receiveVideoTopic']],
56846
- 'uiRemoteAudio': uiRemoteMedias[callTopics['receiveAudioTopic']]*!/
56847
- });
56848
- }*/
56849
-
56850
-
56851
56726
  callStateController.createSessionInChat(Object.assign(params, {
56852
56727
  callVideo: callVideo,
56853
56728
  callAudio: !callMute,
56854
56729
  }));
56855
56730
 
56856
- /*sendCallMessage({
56857
- id: 'STOPALL'
56858
- }, function (result) {*/
56859
-
56860
- /*handleCallSocketOpen({
56861
- brokerAddress: params.brokerAddress,
56862
- turnAddress: params.turnAddress,
56863
- callVideo: callVideo,
56864
- callAudio: !callMute,
56865
- });*/
56866
-
56867
- /* });*/
56868
56731
  } else {
56869
56732
  consoleLogging && console.log('No Call DIV has been declared!');
56870
56733
  return;
@@ -56892,29 +56755,6 @@ WildEmitter.mixin(WildEmitter);
56892
56755
  };
56893
56756
  },
56894
56757
 
56895
- /*handleCallSocketOpen = function (params) {
56896
- currentCallParams = params;
56897
-
56898
- sendCallMessage({
56899
- id: 'CREATE_SESSION',
56900
- brokerAddress: params.brokerAddress,
56901
- turnAddress: params.turnAddress.split(',')[0]
56902
- }, function (res) {
56903
- if (res.done === 'TRUE') {
56904
- callStopQueue.callStarted = true;
56905
- generateAndSendSdpOffers(params, [callTopics['sendVideoTopic'], callTopics['receiveVideoTopic'], callTopics['sendAudioTopic'], callTopics['receiveAudioTopic']]);
56906
- } else if (res.done === 'SKIP') {
56907
- callStopQueue.callStarted = true;
56908
- generateAndSendSdpOffers(params, [callTopics['sendVideoTopic'], callTopics['receiveVideoTopic'], callTopics['sendAudioTopic'], callTopics['receiveAudioTopic']]);
56909
- } else {
56910
- consoleLogging && console.log('CREATE_SESSION faced a problem', res);
56911
- endCall({
56912
- callId: currentCallId
56913
- });
56914
- }
56915
- });
56916
- },*/
56917
-
56918
56758
  callStateController = {
56919
56759
  createSessionInChat: function (params) {
56920
56760
  currentCallParams = params;
@@ -57102,11 +56942,33 @@ WildEmitter.mixin(WildEmitter);
57102
56942
  * @param params
57103
56943
  * @param direction
57104
56944
  */
57105
- removeParticipant: function (user) {
57106
- if(user === chatMessaging.userInfo.id) {
57107
- //TODO: only remove me
57108
- callStop();
56945
+ removeParticipant: function (userId) {
56946
+ var user = callUsers[userId];
56947
+ if(!user)
57109
56948
  return;
56949
+
56950
+ if(user.videoTopicName && user.peers[user.videoTopicName]) {
56951
+ clearInterval(callUsers[userId].topicMetaData[user.videoTopicName].interval);
56952
+ callStateController.removeConnectionQualityInterval(userId, user.videoTopicName);
56953
+ callStateController.removeStreamFromWebRTC(userId, user.videoTopicName);
56954
+ callUsers[userId].peers[user.videoTopicName].dispose();
56955
+ delete callUsers[userId].peers[user.videoTopicName];
56956
+
56957
+ }
56958
+ if(user.audioTopicName && user.peers[user.audioTopicName]) {
56959
+ clearInterval(callUsers[userId].topicMetaData[user.audioTopicName].interval);
56960
+ callStateController.removeConnectionQualityInterval(userId, user.audioTopicName);
56961
+ callStateController.removeStreamFromWebRTC(userId, user.audioTopicName);
56962
+
56963
+ callUsers[userId].peers[user.audioTopicName].dispose();
56964
+ delete callUsers[userId].peers[user.audioTopicName];
56965
+ }
56966
+
56967
+ if(callUsers[userId]){
56968
+ callUsers[userId].peers = {};
56969
+ callUsers[userId].topicMetaData = {};
56970
+ callUsers[userId].htmlElements = {};
56971
+ callUsers[userId] = null;
57110
56972
  }
57111
56973
  },
57112
56974
  stopParticipantAudio: function (userId) {
@@ -57132,8 +56994,8 @@ WildEmitter.mixin(WildEmitter);
57132
56994
  },
57133
56995
  removeTopic: function (userId, topic) {
57134
56996
  if(callUsers[userId].peers[topic]) {
57135
- callUsers[userId].peers[topic].dispose();
57136
56997
  this.removeConnectionQualityInterval(userId, topic);
56998
+ callUsers[userId].peers[topic].dispose();
57137
56999
  callUsers[userId].peers[topic] = null;
57138
57000
  }
57139
57001
  },
@@ -57176,8 +57038,17 @@ WildEmitter.mixin(WildEmitter);
57176
57038
  options[(direction === 'send' ? 'localVideo' : 'remoteVideo')] = callUsers[userId].htmlElements[topic];
57177
57039
 
57178
57040
  if(direction === 'send' && mediaType === 'video' && shareScreen) {
57179
- navigator.mediaDevices.getDisplayMedia().then(function (result) {
57180
- options.videoStream = result;
57041
+ navigator.mediaDevices.getDisplayMedia().then(function (stream) {
57042
+ stream.getVideoTracks()[0].addEventListener("ended", function (event) { // Click on browser UI stop sharing button
57043
+ //callStateController.removeScreenShareFromCall()
57044
+ if(callUsers['screenShare'] && callUsers['screenShare'].peers[topic]){
57045
+ //console.log('event screenShare', currentCallId);
57046
+ currentModuleInstance.endScreenShare({
57047
+ callId: currentCallId
57048
+ });
57049
+ }
57050
+ })
57051
+ options.videoStream = stream;
57181
57052
  options.sendSource = 'screen';
57182
57053
  // options[(direction === 'send' ? 'localVideo' : 'remoteVideo')] = uiRemoteMedias[topic];
57183
57054
  resolve(options);
@@ -57239,7 +57110,8 @@ WildEmitter.mixin(WildEmitter);
57239
57110
  message: 'Poor connection for a long time',
57240
57111
  metadata: {
57241
57112
  elementId: "uiRemoteVideo-" + topic,
57242
- topic: topic
57113
+ topic: topic,
57114
+ userId: userId
57243
57115
  }
57244
57116
  });
57245
57117
  }
@@ -57259,6 +57131,13 @@ WildEmitter.mixin(WildEmitter);
57259
57131
  userMetadata.isConnectionPoor = true;
57260
57132
  userMetadata.poorConnectionCount = 0;
57261
57133
  userMetadata.poorConnectionResolvedCount = 0;
57134
+
57135
+ sendCallMetaData({
57136
+ id: callMetaDataTypes.POORCONNECTION,
57137
+ userid: userId,
57138
+ title: 'Poor Connection',
57139
+ description: topic
57140
+ });
57262
57141
  } else {
57263
57142
  callUsers[userId].topicMetaData[topic].poorConnectionCount++;
57264
57143
  }
@@ -57272,9 +57151,17 @@ WildEmitter.mixin(WildEmitter);
57272
57151
  message: 'Poor connection resolved',
57273
57152
  metadata: {
57274
57153
  elementId: "uiRemoteVideo-" + topic,
57275
- topic: topic
57154
+ topic: topic,
57155
+ userId: userId
57276
57156
  }
57277
57157
  });
57158
+
57159
+ sendCallMetaData({
57160
+ id: callMetaDataTypes.POORCONNECTIONRESOLVED,
57161
+ userid: userId,
57162
+ title: 'Poor Connection Resolved',
57163
+ description: topic
57164
+ });
57278
57165
  } else {
57279
57166
  userMetadata.poorConnectionResolvedCount++;
57280
57167
  }
@@ -57355,12 +57242,12 @@ WildEmitter.mixin(WildEmitter);
57355
57242
  errorInfo: user.peers[topic]
57356
57243
  });
57357
57244
  // setTimeout(function () {
57358
- if(chatMessaging.chatState) {
57359
- callController.shouldReconnectTopic(userId, topic, mediaType, direction);
57360
- }
57361
- // }, 7000);
57362
57245
 
57363
- callController.removeConnectionQualityInterval(userId, topic);
57246
+ if(chatMessaging.chatState) {
57247
+ callController.shouldReconnectTopic(userId, topic, mediaType, direction);
57248
+ }
57249
+ // }, 7000);
57250
+ //callController.removeConnectionQualityInterval(userId, topic);
57364
57251
  }
57365
57252
 
57366
57253
  if(user.peers[topic].peerConnection.connectionState === 'connected') {
@@ -57398,6 +57285,7 @@ WildEmitter.mixin(WildEmitter);
57398
57285
  });
57399
57286
  if(chatMessaging.chatState) {
57400
57287
  callController.shouldReconnectTopic(userId, topic, mediaType, direction);
57288
+ //callController.removeConnectionQualityInterval(userId, topic);
57401
57289
  }
57402
57290
  // } else {
57403
57291
  // setTimeout(function () {
@@ -57437,9 +57325,11 @@ WildEmitter.mixin(WildEmitter);
57437
57325
  topic: topic
57438
57326
  }, function (result) {
57439
57327
  if (result.done === 'TRUE') {
57328
+ clearInterval(callUsers[userId].topicMetaData[topic].interval)
57440
57329
  callController.removeTopic(userId, topic);
57441
57330
  callController.createTopic(userId, topic, mediaType, direction, userId === 'screenShare');
57442
57331
  } else if (result.done === 'SKIP') {
57332
+ clearInterval(callUsers[userId].topicMetaData[topic].interval)
57443
57333
  callController.removeTopic(userId, topic);
57444
57334
  callController.createTopic(userId, topic, mediaType, direction, userId === 'screenShare');
57445
57335
  //generateAndSendSdpOffers(currentCallParams, [topicName]);
@@ -57533,7 +57423,9 @@ WildEmitter.mixin(WildEmitter);
57533
57423
  },
57534
57424
  removeAllCallParticipants: function () {
57535
57425
  var removeAllUsersPromise = new Promise(function (resolve, reject) {
57426
+ var index = 0;
57536
57427
  for (var i in callUsers) {
57428
+ index++;
57537
57429
  var user = callUsers[i];
57538
57430
  if (user) {
57539
57431
  if(user.videoTopicName && user.peers[user.videoTopicName]) {
@@ -57560,7 +57452,8 @@ WildEmitter.mixin(WildEmitter);
57560
57452
  callUsers[i] = null;
57561
57453
  }
57562
57454
 
57563
- resolve()
57455
+ if(index === Object.keys(callUsers).length)
57456
+ resolve();
57564
57457
  }, 200);
57565
57458
  }
57566
57459
  }
@@ -57765,14 +57658,14 @@ WildEmitter.mixin(WildEmitter);
57765
57658
  let newHeight = callVideoMinHeight - (Math.ceil(Math.random() * 50) + 20);
57766
57659
 
57767
57660
  videoTrack.applyConstraints({
57768
- width: {
57769
- min: newWidth,
57770
- ideal: 1280
57771
- },
57772
- height: {
57773
- min: newHeight,
57774
- ideal: 720
57775
- },
57661
+ // width: {
57662
+ // min: newWidth,
57663
+ // ideal: 1280
57664
+ // },
57665
+ // height: {
57666
+ // min: newHeight,
57667
+ // ideal: 720
57668
+ // },
57776
57669
  advanced: [
57777
57670
  {
57778
57671
  width: newWidth,
@@ -57838,6 +57731,12 @@ WildEmitter.mixin(WildEmitter);
57838
57731
  }
57839
57732
  consoleLogging && console.log("[SDK][handleProcessSdpAnswer]", jsonMessage, jsonMessage.topic)
57840
57733
  startMedia(callUsers[userId].htmlElements[jsonMessage.topic]);
57734
+ if(userId === 'screenShare') {
57735
+ restartMediaOnKeyFrame("screenShare", 2000);
57736
+ restartMediaOnKeyFrame("screenShare", 4000);
57737
+ restartMediaOnKeyFrame("screenShare", 8000);
57738
+ restartMediaOnKeyFrame("screenShare", 12000);
57739
+ }
57841
57740
  });
57842
57741
  },
57843
57742
 
@@ -57910,47 +57809,102 @@ WildEmitter.mixin(WildEmitter);
57910
57809
  currentCallId = null;
57911
57810
  },
57912
57811
 
57913
- removeStreamFromWebRTC = function (RTCStream) {
57914
- var callParentDiv = document.getElementById(callDivId);
57812
+ /*
57813
+ removeStreamFromWebRTC = function (RTCStream) {
57814
+ var callParentDiv = document.getElementById(callDivId);
57915
57815
 
57916
- if (uiRemoteMedias.hasOwnProperty(RTCStream)) {
57917
- const stream = uiRemoteMedias[RTCStream].srcObject;
57918
- if (!!stream) {
57919
- const tracks = stream.getTracks();
57816
+ if (uiRemoteMedias.hasOwnProperty(RTCStream)) {
57817
+ const stream = uiRemoteMedias[RTCStream].srcObject;
57818
+ if (!!stream) {
57819
+ const tracks = stream.getTracks();
57920
57820
 
57921
- if (!!tracks) {
57922
- tracks.forEach(function (track) {
57923
- track.stop();
57924
- });
57925
- }
57821
+ if (!!tracks) {
57822
+ tracks.forEach(function (track) {
57823
+ track.stop();
57824
+ });
57825
+ }
57926
57826
 
57927
- uiRemoteMedias[RTCStream].srcObject = null;
57928
- }
57827
+ uiRemoteMedias[RTCStream].srcObject = null;
57828
+ }
57929
57829
 
57930
- uiRemoteMedias[RTCStream].remove();
57931
- delete (uiRemoteMedias[RTCStream]);
57932
- }
57933
- },
57830
+ uiRemoteMedias[RTCStream].remove();
57831
+ delete (uiRemoteMedias[RTCStream]);
57832
+ }
57833
+ },
57934
57834
 
57935
- removeFromCallUI = function (topic) {
57936
- var videoElement = 'Vi-' + topic;
57937
- var audioElement = 'Vo-' + topic;
57938
57835
 
57939
- if (topic.length > 0 && uiRemoteMedias.hasOwnProperty(videoElement)) {
57940
- removeStreamFromWebRTC(videoElement);
57941
- }
57836
+ removeFromCallUI = function (topic) {
57837
+ var videoElement = 'Vi-' + topic;
57838
+ var audioElement = 'Vo-' + topic;
57942
57839
 
57943
- if (topic.length > 0 && uiRemoteMedias.hasOwnProperty(audioElement)) {
57944
- removeStreamFromWebRTC(audioElement);
57945
- }
57946
- },
57840
+ if (topic.length > 0 && uiRemoteMedias.hasOwnProperty(videoElement)) {
57841
+ removeStreamFromWebRTC(videoElement);
57842
+ }
57843
+
57844
+ if (topic.length > 0 && uiRemoteMedias.hasOwnProperty(audioElement)) {
57845
+ removeStreamFromWebRTC(audioElement);
57846
+ }
57847
+ },
57848
+ */
57947
57849
 
57948
57850
  restartMediaOnKeyFrame = function (userId, timeout) {
57949
57851
  setTimeout(function () {
57950
- if(typeof callUsers[chatMessaging.userInfo.id] !== "undefined" && callUsers[chatMessaging.userInfo.id])
57951
- restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
57852
+ if(typeof callUsers[userId] !== "undefined" && callUsers[userId] && callUsers[userId].peers[callUsers[userId].videoTopicName])
57853
+ restartMedia(callUsers[userId].videoTopicName);
57952
57854
  }, timeout);
57953
- };
57855
+ },
57856
+
57857
+ sendCallMetaData = function (params, callback) {
57858
+ var message = {
57859
+ id: params.id,
57860
+ userid: params.userid,
57861
+ title: params.title,
57862
+ description: params.description
57863
+ };
57864
+
57865
+ sendCallMessage({
57866
+ id: 'SENDMETADATA',
57867
+ message: JSON.stringify(message),
57868
+ chatId: currentCallId
57869
+ }, function (res) {
57870
+ callback && callback(res)
57871
+ });
57872
+ },
57873
+ handleReceivedMetaData = function (jsonMessage) {
57874
+ var id = jsonMessage.id;
57875
+ if(!id || typeof id === "undefined" || jsonMessage.userid == chatMessaging.userInfo.id) {
57876
+ return;
57877
+ }
57878
+
57879
+ switch (id) {
57880
+ case callMetaDataTypes.POORCONNECTION:
57881
+ chatEvents.fireEvent("callEvents", {
57882
+ type: 'POOR_VIDEO_CONNECTION',
57883
+ subType: 'SHORT_TIME',
57884
+ message: 'Poor connection detected',
57885
+ metadata: {
57886
+ elementId: "uiRemoteVideo-" + jsonMessage.description,
57887
+ topic: jsonMessage.description,
57888
+ userId: jsonMessage.userid
57889
+ }
57890
+ });
57891
+ break;
57892
+ case callMetaDataTypes.POORCONNECTIONRESOLVED:
57893
+ chatEvents.fireEvent('callEvents', {
57894
+ type: 'POOR_VIDEO_CONNECTION_RESOLVED',
57895
+ message: 'Poor connection resolved',
57896
+ metadata: {
57897
+ elementId: "uiRemoteVideo-" + jsonMessage.description,
57898
+ topic: jsonMessage.description,
57899
+ userId: jsonMessage.userid
57900
+ }
57901
+ });
57902
+ break;
57903
+ }
57904
+
57905
+ }
57906
+
57907
+
57954
57908
 
57955
57909
  this.updateToken = function (newToken) {
57956
57910
  token = newToken;
@@ -57975,26 +57929,21 @@ WildEmitter.mixin(WildEmitter);
57975
57929
  break;
57976
57930
 
57977
57931
  case 'GET_KEY_FRAME':
57978
- restartMediaOnKeyFrame(chatMessaging.userInfo.id, 2000);
57979
- restartMediaOnKeyFrame(chatMessaging.userInfo.id, 4000);
57980
- restartMediaOnKeyFrame(chatMessaging.userInfo.id, 8000);
57981
- restartMediaOnKeyFrame(chatMessaging.userInfo.id, 12000);
57982
- /* setTimeout(function () {
57983
- if(typeof callUsers[chatMessaging.userInfo.id] === "undefined" || !callUsers[chatMessaging.userInfo.id])
57984
- restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
57985
- }, 2000);
57986
- setTimeout(function () {
57987
- if(typeof callUsers[chatMessaging.userInfo.id] === "undefined" || !callUsers[chatMessaging.userInfo.id])
57988
- restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
57989
- }, 4000);
57990
- setTimeout(function () {
57991
- if(typeof callUsers[chatMessaging.userInfo.id] === "undefined" || !callUsers[chatMessaging.userInfo.id])
57992
- restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
57993
- }, 8000);
57994
- setTimeout(function () {
57995
- if(typeof callUsers[chatMessaging.userInfo.id] === "undefined" || !callUsers[chatMessaging.userInfo.id])
57996
- restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
57997
- }, 12000);*/
57932
+ if(callUsers && callUsers[chatMessaging.userInfo.id] && callUsers[chatMessaging.userInfo.id].video) {
57933
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 2000);
57934
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 4000);
57935
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 8000);
57936
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 12000);
57937
+ }
57938
+ if(callUsers && callUsers['screenShare']
57939
+ && callUsers['screenShare'].video
57940
+ && screenShareState.started
57941
+ && screenShareState.imOwner) {
57942
+ restartMediaOnKeyFrame('screenShare', 2000);
57943
+ restartMediaOnKeyFrame('screenShare', 4000);
57944
+ restartMediaOnKeyFrame('screenShare', 8000);
57945
+ restartMediaOnKeyFrame('screenShare', 12000);
57946
+ }
57998
57947
  break;
57999
57948
 
58000
57949
  case 'FREEZED':
@@ -58006,11 +57955,13 @@ WildEmitter.mixin(WildEmitter);
58006
57955
  chatMessaging.messagesCallbacks[uniqueId](jsonMessage);
58007
57956
  }
58008
57957
  break;*/
57958
+
58009
57959
  case 'STOP':
58010
57960
  if (chatMessaging.messagesCallbacks[uniqueId]) {
58011
57961
  chatMessaging.messagesCallbacks[uniqueId](jsonMessage);
58012
57962
  }
58013
57963
  break;
57964
+
58014
57965
  case 'CLOSE':
58015
57966
  if (chatMessaging.messagesCallbacks[uniqueId]) {
58016
57967
  chatMessaging.messagesCallbacks[uniqueId](jsonMessage);
@@ -58029,6 +57980,14 @@ WildEmitter.mixin(WildEmitter);
58029
57980
  }
58030
57981
  break;
58031
57982
 
57983
+ case 'RECEIVEMETADATA':
57984
+ // if (chatMessaging.messagesCallbacks[uniqueId]) {
57985
+ // chatMessaging.messagesCallbacks[uniqueId](jsonMessage);
57986
+ // }
57987
+ handleReceivedMetaData(JSON.parse(jsonMessage.message));
57988
+
57989
+ break;
57990
+
58032
57991
  case 'ERROR':
58033
57992
  handleError(jsonMessage, params.sendingTopic, params.receiveTopic);
58034
57993
  break;
@@ -58075,7 +58034,7 @@ WildEmitter.mixin(WildEmitter);
58075
58034
  result: messageContent
58076
58035
  });
58077
58036
 
58078
- currentCallId = messageContent.callId;
58037
+ //currentCallId = messageContent.callId;
58079
58038
 
58080
58039
  break;
58081
58040
 
@@ -58122,6 +58081,11 @@ WildEmitter.mixin(WildEmitter);
58122
58081
  type: 'RECEIVE_CALL',
58123
58082
  result: messageContent
58124
58083
  });
58084
+
58085
+ if(!currentCallId)
58086
+ currentCallId = messageContent.callId;
58087
+ else
58088
+ newCallId = messageContent.callId;
58125
58089
  } else {
58126
58090
  chatEvents.fireEvent('callEvents', {
58127
58091
  type: 'PARTNER_RECEIVED_YOUR_CALL',
@@ -58129,7 +58093,7 @@ WildEmitter.mixin(WildEmitter);
58129
58093
  });
58130
58094
  }
58131
58095
 
58132
- currentCallId = messageContent.callId;
58096
+
58133
58097
 
58134
58098
  break;
58135
58099
 
@@ -58170,6 +58134,7 @@ WildEmitter.mixin(WildEmitter);
58170
58134
  screenShare: messageContent.chatDataDto.screenShare,
58171
58135
  brokerAddress: messageContent.chatDataDto.brokerAddressWeb,
58172
58136
  turnAddress: messageContent.chatDataDto.turnAddress,
58137
+ selfData: messageContent.clientDTO,
58173
58138
  clientsList: messageContent.otherClientDtoList
58174
58139
  }, function (callDivs) {
58175
58140
  chatEvents.fireEvent('callEvents', {
@@ -58213,10 +58178,11 @@ WildEmitter.mixin(WildEmitter);
58213
58178
 
58214
58179
  chatEvents.fireEvent('callEvents', {
58215
58180
  type: 'CALL_ENDED',
58216
- result: messageContent
58181
+ callId: threadId
58217
58182
  });
58218
58183
 
58219
- callStop();
58184
+ if(threadId === currentCallId)
58185
+ callStop();
58220
58186
 
58221
58187
  break;
58222
58188
 
@@ -58257,8 +58223,9 @@ WildEmitter.mixin(WildEmitter);
58257
58223
  type: 'CALL_PARTICIPANT_CONNECTED',
58258
58224
  result: messageContent
58259
58225
  });
58260
-
58261
- restartMedia(callTopics['sendVideoTopic']);
58226
+ //callTopics['sendVideoTopic']
58227
+ //restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
58228
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 100)
58262
58229
 
58263
58230
  break;
58264
58231
 
@@ -58276,10 +58243,10 @@ WildEmitter.mixin(WildEmitter);
58276
58243
  * Type 91 Send Group Call Request
58277
58244
  */
58278
58245
  case chatMessageVOTypes.GROUP_CALL_REQUEST:
58246
+ callRequestController.callRequestReceived = true;
58279
58247
  callReceived({
58280
58248
  callId: messageContent.callId
58281
- }, function (r) {
58282
- });
58249
+ }, function (r) {});
58283
58250
 
58284
58251
  if (chatMessaging.messagesCallbacks[uniqueId]) {
58285
58252
  chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
@@ -58290,7 +58257,7 @@ WildEmitter.mixin(WildEmitter);
58290
58257
  result: messageContent
58291
58258
  });
58292
58259
 
58293
- currentCallId = messageContent.callId;
58260
+ //currentCallId = messageContent.callId;
58294
58261
 
58295
58262
  break;
58296
58263
 
@@ -58307,9 +58274,16 @@ WildEmitter.mixin(WildEmitter);
58307
58274
  result: messageContent
58308
58275
  });
58309
58276
 
58310
- if (!!messageContent[0].sendTopic) {
58311
- //removeFromCallUI(messageContent[0].sendTopic);
58312
- callStateController.removeFromCallUI(messageContent[0].sendTopic)
58277
+ if (!!messageContent[0].userId) {
58278
+ //callStateController.removeFromCallUI(messageContent[0].sendTopic)
58279
+ callStateController.removeParticipant(messageContent[0].userId);
58280
+ }
58281
+
58282
+ //If I'm the only call participant, stop the call
58283
+ if(callUsers) {
58284
+ if(Object.values(callUsers).length < 2) {
58285
+ callStop()
58286
+ }
58313
58287
  }
58314
58288
 
58315
58289
  break;
@@ -58331,14 +58305,36 @@ WildEmitter.mixin(WildEmitter);
58331
58305
  if (chatMessaging.messagesCallbacks[uniqueId]) {
58332
58306
  chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
58333
58307
  }
58308
+ if(Array.isArray(messageContent)) {
58309
+ for (var i in messageContent) {
58310
+ var correctedData = {
58311
+ video: messageContent[i].video,
58312
+ mute: messageContent[i].mute,
58313
+ userId: messageContent[i].userId,
58314
+ topicSend: messageContent[i].sendTopic
58315
+ }
58316
+ callStateController.setupCallParticipant(correctedData);
58317
+ if(correctedData.video) {
58318
+ callStateController.startParticipantVideo(correctedData.userId);
58319
+ }
58320
+ if(!correctedData.mute) {
58321
+ callStateController.startParticipantAudio(correctedData.userId);
58322
+ }
58323
+ }
58324
+ }
58325
+
58326
+ chatEvents.fireEvent('callEvents', {
58327
+ type: 'CALL_DIVS',
58328
+ result: generateCallUIList()
58329
+ });
58334
58330
 
58335
58331
  chatEvents.fireEvent('callEvents', {
58336
58332
  type: 'CALL_PARTICIPANT_JOINED',
58337
58333
  result: messageContent
58338
58334
  });
58339
58335
 
58340
- restartMedia(callTopics['sendVideoTopic']);
58341
-
58336
+ //restartMedia(callTopics['sendVideoTopic']);
58337
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 100)
58342
58338
  break;
58343
58339
 
58344
58340
  /**
@@ -58388,18 +58384,15 @@ WildEmitter.mixin(WildEmitter);
58388
58384
  'audioTopicName',
58389
58385
  'mute'
58390
58386
  )
58391
- /*if(callUsers[messageContent[i].userId]) {
58392
- callUsers[messageContent[i].userId].mute = true;
58393
-
58394
- var user = callUsers[messageContent[i].userId];
58395
- clearInterval(callUsers[messageContent[i].userId].topicMetaData[user.audioTopicName].interval)
58396
- callStateController.removeTopic(messageContent[i].userId, user.audioTopicName);
58397
- callStateController.removeStreamFromWebRTC(messageContent[i].userId, user.audioTopicName);
58398
- }*/
58399
58387
  }
58400
58388
  }
58401
58389
  }
58402
58390
 
58391
+ chatEvents.fireEvent('callEvents', {
58392
+ type: 'CALL_DIVS',
58393
+ result: generateCallUIList()
58394
+ });
58395
+
58403
58396
  chatEvents.fireEvent('callEvents', {
58404
58397
  type: 'CALL_PARTICIPANT_MUTE',
58405
58398
  result: messageContent
@@ -58424,21 +58417,15 @@ WildEmitter.mixin(WildEmitter);
58424
58417
  messageContent[i].sendTopic,
58425
58418
  'mute'
58426
58419
  );
58427
- /*if(callUsers[messageContent[i].userId]) {
58428
- callUsers[messageContent[i].userId].mute = false;
58429
- callUsers[messageContent[i].userId].audioTopicName = 'Vo-' + messageContent[i].sendTopic;
58430
-
58431
- var user = callUsers[messageContent[i].userId];
58432
- callStateController.appendUserToCallDiv(messageContent[i].userId, callStateController.generateHTMLElements(messageContent[i].userId));
58433
- setTimeout(function () {
58434
- callStateController.createTopic(messageContent[i].userId, user.audioTopicName, 'audio', 'receive');
58435
-
58436
- })
58437
- }*/
58438
58420
  }
58439
58421
  }
58440
58422
  }
58441
58423
 
58424
+ chatEvents.fireEvent('callEvents', {
58425
+ type: 'CALL_DIVS',
58426
+ result: generateCallUIList()
58427
+ });
58428
+
58442
58429
  chatEvents.fireEvent('callEvents', {
58443
58430
  type: 'CALL_PARTICIPANT_UNMUTE',
58444
58431
  result: messageContent
@@ -58467,7 +58454,12 @@ WildEmitter.mixin(WildEmitter);
58467
58454
  result: messageContent
58468
58455
  });
58469
58456
 
58470
- currentCallId = messageContent.callId;
58457
+ if(!currentCallId)
58458
+ currentCallId = messageContent.callId;
58459
+ else
58460
+ newCallId = messageContent.callId;
58461
+
58462
+ //currentCallId = messageContent.callId;
58471
58463
 
58472
58464
  break;
58473
58465
 
@@ -58488,16 +58480,6 @@ WildEmitter.mixin(WildEmitter);
58488
58480
  messageContent[i].sendTopic,
58489
58481
  'video'
58490
58482
  );
58491
- /*if(callUsers[messageContent[i].userId]) {
58492
- callUsers[messageContent[i].userId].video = true;
58493
- callUsers[messageContent[i].userId].videoTopicName = 'Vi-' + messageContent[i].sendTopic;
58494
-
58495
- var user = callUsers[messageContent[i].userId];
58496
- callStateController.appendUserToCallDiv(messageContent[i].userId, callStateController.generateHTMLElements(messageContent[i].userId));
58497
- setTimeout(function () {
58498
- callStateController.createTopic(messageContent[i].userId, user.videoTopicName, 'video', 'receive');
58499
- })
58500
- }*/
58501
58483
  }
58502
58484
  }
58503
58485
  }
@@ -58530,13 +58512,6 @@ WildEmitter.mixin(WildEmitter);
58530
58512
  'videoTopicName',
58531
58513
  'video'
58532
58514
  )
58533
- /* if(callUsers[messageContent[i].userId]) {
58534
- callUsers[messageContent[i].userId].video = false;
58535
- var user = callUsers[messageContent[i].userId];
58536
- clearInterval(callUsers[messageContent[i].userId].topicMetaData[user.videoTopicName].interval)
58537
- callStateController.removeTopic(messageContent[i].userId, user.videoTopicName);
58538
- callStateController.removeStreamFromWebRTC(messageContent[i].userId, user.videoTopicName);
58539
- }*/
58540
58515
  }
58541
58516
  }
58542
58517
  }
@@ -58568,7 +58543,15 @@ WildEmitter.mixin(WildEmitter);
58568
58543
  result: messageContent
58569
58544
  });
58570
58545
 
58571
- restartMedia(callTopics['sendVideoTopic']);
58546
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 4000);
58547
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 8000);
58548
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 12000);
58549
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 25000);
58550
+
58551
+ restartMediaOnKeyFrame("screenShare", 4000);
58552
+ restartMediaOnKeyFrame("screenShare", 8000);
58553
+ restartMediaOnKeyFrame("screenShare", 12000);
58554
+ restartMediaOnKeyFrame("screenShare", 25000);
58572
58555
 
58573
58556
  break;
58574
58557
 
@@ -58665,7 +58648,15 @@ WildEmitter.mixin(WildEmitter);
58665
58648
  result: messageContent
58666
58649
  });
58667
58650
 
58668
- restartMedia(callTopics['sendVideoTopic']);
58651
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 4000);
58652
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 8000);
58653
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 12000);
58654
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 25000);
58655
+
58656
+ restartMediaOnKeyFrame("screenShare", 4000);
58657
+ restartMediaOnKeyFrame("screenShare", 8000);
58658
+ restartMediaOnKeyFrame("screenShare", 12000);
58659
+ restartMediaOnKeyFrame("screenShare", 25000);
58669
58660
 
58670
58661
  break;
58671
58662
  }
@@ -58694,8 +58685,8 @@ WildEmitter.mixin(WildEmitter);
58694
58685
 
58695
58686
  if (params.clientType
58696
58687
  && typeof params.clientType === 'string'
58697
- && callClientTypes[params.clientType.toUpperCase()] > 0) {
58698
- content.creatorClientDto.clientType = callClientTypes[params.clientType.toUpperCase()];
58688
+ && callClientType[params.clientType.toUpperCase()] > 0) {
58689
+ content.creatorClientDto.clientType = callClientType[params.clientType.toUpperCase()];
58699
58690
  } else {
58700
58691
  content.creatorClientDto.clientType = callClientType.WEB;
58701
58692
  }
@@ -58704,13 +58695,14 @@ WildEmitter.mixin(WildEmitter);
58704
58695
  content.threadId = +params.threadId;
58705
58696
  } else {
58706
58697
  if (Array.isArray(params.invitees)) {
58707
- content.invitees = [];
58708
- for (var i = 0; i < params.invitees.length; i++) {
58709
- var tempInvitee = formatDataToMakeInvitee(params.invitees[i]);
58710
- if (tempInvitee) {
58711
- content.invitees.push(tempInvitee);
58712
- }
58713
- }
58698
+ content.invitees = params.invitees;
58699
+
58700
+ //for (var i = 0; i < params.invitees.length; i++) {
58701
+ //var tempInvitee = params.invitees[i];
58702
+ //if (tempInvitee) {
58703
+ //content.invitees.push(tempInvitee);
58704
+ //}
58705
+ //}
58714
58706
  } else {
58715
58707
  chatEvents.fireEvent('error', {
58716
58708
  code: 999,
@@ -58759,8 +58751,8 @@ WildEmitter.mixin(WildEmitter);
58759
58751
 
58760
58752
  content.creatorClientDto.mute = (typeof params.mute === 'boolean') ? params.mute : false;
58761
58753
 
58762
- if (params.clientType && typeof params.clientType === 'string' && callClientTypes[params.clientType.toUpperCase()] > 0) {
58763
- content.creatorClientDto.clientType = callClientTypes[params.clientType.toUpperCase()];
58754
+ if (params.clientType && typeof params.clientType === 'string' && callClientType[params.clientType.toUpperCase()] > 0) {
58755
+ content.creatorClientDto.clientType = callClientType[params.clientType.toUpperCase()];
58764
58756
  } else {
58765
58757
  content.creatorClientDto.clientType = callClientType.WEB;
58766
58758
  }
@@ -58769,13 +58761,14 @@ WildEmitter.mixin(WildEmitter);
58769
58761
  content.threadId = +params.threadId;
58770
58762
  } else {
58771
58763
  if (Array.isArray(params.invitees)) {
58772
- content.invitees = [];
58773
- for (var i = 0; i < params.invitees.length; i++) {
58774
- var tempInvitee = formatDataToMakeInvitee(params.invitees[i]);
58775
- if (tempInvitee) {
58776
- content.invitees.push(tempInvitee);
58777
- }
58778
- }
58764
+ content.invitees = params.invitees;
58765
+
58766
+ //for (var i = 0; i < params.invitees.length; i++) {
58767
+ //var tempInvitee = params.invitees[i];
58768
+ //if (tempInvitee) {
58769
+ //content.invitees.push(tempInvitee);
58770
+ //}
58771
+ //}
58779
58772
  } else {
58780
58773
  chatEvents.fireEvent('error', {
58781
58774
  code: 999,
@@ -58794,6 +58787,10 @@ WildEmitter.mixin(WildEmitter);
58794
58787
  return;
58795
58788
  }
58796
58789
 
58790
+ callRequestController.cameraPaused = (typeof params.cameraPaused === 'boolean') ? params.cameraPaused : false;
58791
+ callRequestController.callRequestReceived = true;
58792
+ callRequestController.callEstablishedInMySide = true;
58793
+
58797
58794
  return chatMessaging.sendMessage(startCallData, {
58798
58795
  onResult: function (result) {
58799
58796
  callback && callback(result);
@@ -58865,8 +58862,8 @@ WildEmitter.mixin(WildEmitter);
58865
58862
 
58866
58863
  callRequestController.cameraPaused = (typeof params.cameraPaused === 'boolean') ? params.cameraPaused : callRequestController.cameraPaused;
58867
58864
 
58868
- if (params.clientType && typeof params.clientType === 'string' && callClientTypes[params.clientType.toUpperCase()] > 0) {
58869
- content.clientType = callClientTypes[params.clientType.toUpperCase()];
58865
+ if (params.clientType && typeof params.clientType === 'string' && callClientType[params.clientType.toUpperCase()] > 0) {
58866
+ content.clientType = callClientType[params.clientType.toUpperCase()];
58870
58867
  } else {
58871
58868
  content.clientType = callClientType.WEB;
58872
58869
  }
@@ -58958,7 +58955,8 @@ WildEmitter.mixin(WildEmitter);
58958
58955
 
58959
58956
  return chatMessaging.sendMessage(recordCallData, {
58960
58957
  onResult: function (result) {
58961
- restartMedia(callTopics['sendVideoTopic']);
58958
+ //restartMedia(callTopics['sendVideoTopic']);
58959
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 100)
58962
58960
  callback && callback(result);
58963
58961
  }
58964
58962
  });
@@ -59412,10 +59410,6 @@ WildEmitter.mixin(WildEmitter);
59412
59410
  'audioTopicName',
59413
59411
  'mute'
59414
59412
  )
59415
- /*
59416
- callStateController.removeTopic(chatMessaging.userInfo.id, callUsers[chatMessaging.userInfo.id].audioTopicName)
59417
- callStateController.removeStreamFromWebRTC(chatMessaging.userInfo.id, callUsers[chatMessaging.userInfo.id].audioTopicName)
59418
- */
59419
59413
 
59420
59414
  return chatMessaging.sendMessage(sendMessageParams, {
59421
59415
  onResult: function (result) {
@@ -59467,16 +59461,6 @@ WildEmitter.mixin(WildEmitter);
59467
59461
  callUsers[myId].topicSend,
59468
59462
  'mute'
59469
59463
  );
59470
- /*if(callUsers[myId]) {
59471
- callUsers[myId].mute = false;
59472
- callUsers[myId].audioTopicName = 'Vo-' + callUsers[myId].topicSend;
59473
-
59474
- var user = callUsers[myId];
59475
- callStateController.appendUserToCallDiv(myId, callStateController.generateHTMLElements(myId));
59476
- setTimeout(function () {
59477
- callStateController.createTopic(myId, user.audioTopicName, 'audio', 'send');
59478
- })
59479
- }*/
59480
59464
 
59481
59465
  return chatMessaging.sendMessage(sendMessageParams, {
59482
59466
  onResult: function (result) {
@@ -73248,25 +73232,22 @@ WildEmitter.mixin(WildEmitter);
73248
73232
 
73249
73233
  if(stackArr.length < wantedCount) {
73250
73234
  stepCount = wantedCount - stackArr.length < stepCount ? wantedCount - stackArr.length : stepCount;
73235
+ //setTimeout(function () {
73251
73236
  resolve(requestExportChat(stackArr, wantedCount, stepCount, stackArr.length, sendData));
73237
+ //}, 1000)
73252
73238
  } else {
73253
73239
  resolve(stackArr);
73254
73240
  }
73255
73241
  });
73256
- /*returnData.result = result;*/
73257
- /*var messageContent = result.result,
73258
- messageLength = messageContent.length,
73259
- resultData = {
73260
- participants: formatDataToMakeAssistantHistoryList(messageContent),
73261
- contentCount: result.contentCount,
73262
- hasNext: (sendData.content.offset + sendData.content.count < result.contentCount && messageLength > 0),
73263
- nextOffset: sendData.content.offset * 1 + messageLength * 1
73264
- };
73265
-
73266
- returnData.result = resultData;*/
73267
73242
  } else {
73268
- consoleLogging && console.log("[SDK][exportChat] Problem in one step... . Rerunning the request.", wantedCount, stepCount, stackArr.length, sendData, result);
73269
- resolve(requestExportChat(stackArr, wantedCount, stepCount, stackArr.length, sendData))
73243
+ if(result.errorCode !== 21) {
73244
+ consoleLogging && console.log("[SDK][exportChat] Problem in one step... . Rerunning the request.", wantedCount, stepCount, stackArr.length, sendData, result);
73245
+ setTimeout(function () {
73246
+ resolve(requestExportChat(stackArr, wantedCount, stepCount, stackArr.length, sendData))
73247
+ }, 2000)
73248
+ } else {
73249
+ reject(result)
73250
+ }
73270
73251
  }
73271
73252
  }
73272
73253
  });
@@ -73305,9 +73286,10 @@ WildEmitter.mixin(WildEmitter);
73305
73286
  offset = params.offset;
73306
73287
  }
73307
73288
 
73308
- if (params.messageType && typeof params.messageType.toUpperCase() !== 'undefined' && chatMessageTypes[params.messageType.toUpperCase()] > 0) {
73309
- sendData.content.messageType = chatMessageTypes[params.messageType.toUpperCase()];
73310
- }
73289
+ // if (params.messageType && typeof params.messageType.toUpperCase() !== 'undefined' && chatMessageTypes[params.messageType.toUpperCase()] > 0) {
73290
+ // sendData.content.messageType = chatMessageTypes[params.messageType.toUpperCase()];
73291
+ // }
73292
+ sendData.content.messageType = 1;
73311
73293
 
73312
73294
  if(wantedCount < stepCount)
73313
73295
  stepCount = wantedCount;
@@ -73320,7 +73302,46 @@ WildEmitter.mixin(WildEmitter);
73320
73302
  responseType = params.responseType !== null ? params.responseType : "blob",
73321
73303
  autoStartDownload = params.autoStartDownload !== null ? params.autoStartDownload : true
73322
73304
 
73323
- var blob = new Blob([Utility.convertToCSV(result)], { type: 'text/csv;charset=utf-8;' });
73305
+ var str = ''
73306
+ , universalBOM = "\uFEFF";
73307
+
73308
+ str += "\u{62A}\u{627}\u{631}\u{6CC}\u{62E} " + ','; //tarikh
73309
+ str += " \u{633}\u{627}\u{639}\u{62A} " + ','; //saat
73310
+ str += "\u{646}\u{627}\u{645} \u{641}\u{631}\u{633}\u{62A}\u{646}\u{62F}\u{647}" + ',';//name ferestande
73311
+ str += "\u{646}\u{627}\u{645} \u{6A9}\u{627}\u{631}\u{628}\u{631}\u{6CC} \u{641}\u{631}\u{633}\u{62A}\u{646}\u{62F}\u{647}" + ','; //name karbariye ferestande
73312
+ str += "\u{645}\u{62A}\u{646} \u{67E}\u{6CC}\u{627}\u{645}" + ',';//matne payam
73313
+ str += '\r\n';
73314
+ var line = '', radif = 1;
73315
+ for (var i = 0; i < result.length; i++) {
73316
+ line = '';
73317
+
73318
+ if(result[i].messageType !== 1) {
73319
+ continue;
73320
+ }
73321
+
73322
+ var sender = '';
73323
+ if(result[i].participant.contactName) {
73324
+ sender = result[i].participant.contactName + ',';
73325
+ } else {
73326
+ if(result[i].participant.firstName) {
73327
+ sender = result[i].participant.firstName + ' ';
73328
+ }
73329
+ if(result[i].participant.lastName) {
73330
+ sender += result[i].participant.lastName;
73331
+ }
73332
+ sender += ','
73333
+ }
73334
+
73335
+ line += new Date(result[i].time).toLocaleDateString('fa-IR') + ',';
73336
+ line += new Date(result[i].time).toLocaleTimeString('fa-IR') + ',';
73337
+ line += sender;
73338
+ line += result[i].participant.username + ',';
73339
+ line += result[i].message.replaceAll(",", ".").replace(/(\r\n|\n|\r)/gm, " ") + ',';
73340
+
73341
+ str += line + '\r\n';
73342
+ radif++;
73343
+ }
73344
+ var blob = new Blob([str], { type: 'text/csv;charset=utf-8;' });
73324
73345
  chatEvents.fireEvent('threadEvents', {
73325
73346
  type: 'EXPORT_CHAT',
73326
73347
  subType: 'DONE',
@@ -73343,7 +73364,7 @@ WildEmitter.mixin(WildEmitter);
73343
73364
  url = URL.createObjectURL(blob);
73344
73365
  //if (link.download !== undefined) { // feature detection
73345
73366
  // Browsers that support HTML5 download attribute
73346
- link.setAttribute("href", url);
73367
+ link.setAttribute("href", 'data:text/csv; charset=utf-8,' + encodeURIComponent(universalBOM + str));
73347
73368
  link.setAttribute("download", exportedFilename);
73348
73369
  if(autoStartDownload) {
73349
73370
  link.style.visibility = 'hidden';
@@ -73366,7 +73387,9 @@ WildEmitter.mixin(WildEmitter);
73366
73387
  }
73367
73388
  //}
73368
73389
  callback = undefined;
73369
- });
73390
+ })/*.catch(function (result) {
73391
+ consoleLogging && console.log(result);
73392
+ });*/
73370
73393
  }
73371
73394
 
73372
73395
  this.startCall = callModule.startCall;