podchat-browser 11.3.3 → 11.3.4

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.
@@ -30,7 +30,7 @@
30
30
  <script type="text/javascript">
31
31
  // Developement
32
32
  var PodChat = window.POD.Chat;
33
- var env = 'sandbox'; // main | sandbox | integration
33
+ var env = 'main'; // main | sandbox | integration
34
34
 
35
35
  var params = {
36
36
  appId: new Date().getTime(),
@@ -1955,10 +1955,10 @@ Thread: <input type="text" id="threadInput" autocomplete="on" width="500">
1955
1955
  <fieldset>
1956
1956
  <legend>Send File Message</legend>
1957
1957
  <label for="sendFileThread">Thread Id</label>
1958
- <input type="text" name="sendFileThread" id="sendFileThread" value="54436" class="custom-thread-id">
1958
+ <input type="text" name="sendFileThread" id="sendFileThread" value="972967" class="custom-thread-id">
1959
1959
  <br>
1960
1960
  <label for="sendFileUserGroupHash">Thread userGroupHash</label>
1961
- <input type="text" name="sendFileUserGroupHash" id="sendFileUserGroupHash" value="5GW93QH695O7HC">
1961
+ <input type="text" name="sendFileUserGroupHash" id="sendFileUserGroupHash" value="EY8X3CYDZQ9QBQ">
1962
1962
  <br>
1963
1963
 
1964
1964
  <label for="sendFileMessageType">Message Type</label>
@@ -1979,6 +1979,7 @@ Thread: <input type="text" id="threadInput" autocomplete="on" width="500">
1979
1979
  <label for="sendFileDescription">Description: </label>
1980
1980
  <textarea type="text" name="sendFileDescription" id="sendFileDescription"></textarea>
1981
1981
  <button type="button" name="button" id="sendFileMessage">Send File Message</button>
1982
+ <button type="button" name="button" id="sendMultipleFileMessage">Send Multiple File Message</button>
1982
1983
  </fieldset>
1983
1984
  </form>
1984
1985
 
@@ -2614,6 +2615,63 @@ Thread: <input type="text" id="threadInput" autocomplete="on" width="500">
2614
2615
  // }, 100);
2615
2616
  });
2616
2617
 
2618
+ /**
2619
+ * SEND MULTIPLE FILES
2620
+ */
2621
+ document.getElementById("sendMultipleFileMessage")
2622
+ .addEventListener("click", function (e) {
2623
+ e.preventDefault();
2624
+ var fileInput = document.getElementById("sendFileInput"),
2625
+ image = fileInput.files[0],
2626
+ content = document.getElementById("sendFileDescription").value,
2627
+ thread = document.getElementById("sendFileThread").value,
2628
+ messageType = document.getElementById("sendFileMessageType").value,
2629
+ userGroupHash = document.getElementById("sendFileUserGroupHash").value;
2630
+
2631
+ for(var i =1; i<= 5; i++) {
2632
+ setTimeout(function () {
2633
+ var instantResult = chatAgent.sendFileMessage({
2634
+ threadId: thread,
2635
+ file: image,
2636
+ content: content,
2637
+ userGroupHash: userGroupHash,
2638
+ messageType: messageType,
2639
+ metadata: {
2640
+ custom_name: "John Doe"
2641
+ }
2642
+ }, {
2643
+ onResult: function (result) {
2644
+ if (result.hasError) {
2645
+ console.log('[examples/html] upload of an item failed', result)
2646
+ }
2647
+ },
2648
+ onSent: function (result) {
2649
+ console.log(result);
2650
+ console.log(result.uniqueId + " \t has been Sent!");
2651
+ },
2652
+ onDeliver: function (result) {
2653
+ console.log(result.uniqueId + " \t has been Delivered!");
2654
+ },
2655
+ onSeen: function (result) {
2656
+ console.log(result.uniqueId + " \t has been Seen!");
2657
+ },
2658
+ onFileUpload: function (result) {
2659
+ console.log('File Upload is done', result);
2660
+ }
2661
+ });
2662
+ console.log("Instant sendFile Results", instantResult)
2663
+ }, i * 5000);
2664
+ }
2665
+
2666
+ // console.log("Should cancel file upload after 100ms. (uid = " + instantResult.content.file.uniqueId + ")")
2667
+ // setTimeout(() => {
2668
+ // chatAgent.cancelFileUpload({
2669
+ // uniqueId: instantResult.content.file.uniqueId
2670
+ // }, function() {
2671
+ // console.log("Upload has been Canceled!");
2672
+ // });
2673
+ // }, 100);
2674
+ })
2617
2675
 
2618
2676
  /**
2619
2677
  * REPLY FILE MESSAGE
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "podchat-browser",
3
- "version": "11.3.3",
3
+ "version": "11.3.4",
4
4
  "description": "Javascript SDK to use POD's Chat Service - Browser Only",
5
5
  "main": "./src/chat.js",
6
6
  "scripts": {
7
7
  "test": "mocha --reporter spec --exit",
8
- "bundle": "browserify browser-bundling.js -o ./dist/podchat-11.3.3.js",
8
+ "bundle": "browserify browser-bundling.js -o ./dist/podchat-11.3.4.js",
9
9
  "publish:snapshot": "npm run version:snapshot && npm publish --tag snapshot",
10
10
  "version:snapshot": "npm version prerelease --preid snapshot",
11
11
  "publish:release": "npm run version:release && npm publish",
12
- "version:release": "npm version 11.3.3"
12
+ "version:release": "npm version 11.3.4"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
@@ -681,29 +681,6 @@
681
681
  };
682
682
  },
683
683
 
684
- /*handleCallSocketOpen = function (params) {
685
- currentCallParams = params;
686
-
687
- sendCallMessage({
688
- id: 'CREATE_SESSION',
689
- brokerAddress: params.brokerAddress,
690
- turnAddress: params.turnAddress.split(',')[0]
691
- }, function (res) {
692
- if (res.done === 'TRUE') {
693
- callStopQueue.callStarted = true;
694
- generateAndSendSdpOffers(params, [callTopics['sendVideoTopic'], callTopics['receiveVideoTopic'], callTopics['sendAudioTopic'], callTopics['receiveAudioTopic']]);
695
- } else if (res.done === 'SKIP') {
696
- callStopQueue.callStarted = true;
697
- generateAndSendSdpOffers(params, [callTopics['sendVideoTopic'], callTopics['receiveVideoTopic'], callTopics['sendAudioTopic'], callTopics['receiveAudioTopic']]);
698
- } else {
699
- consoleLogging && console.log('CREATE_SESSION faced a problem', res);
700
- endCall({
701
- callId: currentCallId
702
- });
703
- }
704
- });
705
- },*/
706
-
707
684
  callStateController = {
708
685
  createSessionInChat: function (params) {
709
686
  currentCallParams = params;
@@ -921,8 +898,8 @@
921
898
  },
922
899
  removeTopic: function (userId, topic) {
923
900
  if(callUsers[userId].peers[topic]) {
924
- callUsers[userId].peers[topic].dispose();
925
901
  this.removeConnectionQualityInterval(userId, topic);
902
+ callUsers[userId].peers[topic].dispose();
926
903
  callUsers[userId].peers[topic] = null;
927
904
  }
928
905
  },
@@ -1144,12 +1121,12 @@
1144
1121
  errorInfo: user.peers[topic]
1145
1122
  });
1146
1123
  // setTimeout(function () {
1147
- if(chatMessaging.chatState) {
1148
- callController.shouldReconnectTopic(userId, topic, mediaType, direction);
1149
- }
1150
- // }, 7000);
1151
1124
 
1152
- callController.removeConnectionQualityInterval(userId, topic);
1125
+ if(chatMessaging.chatState) {
1126
+ callController.shouldReconnectTopic(userId, topic, mediaType, direction);
1127
+ }
1128
+ // }, 7000);
1129
+ //callController.removeConnectionQualityInterval(userId, topic);
1153
1130
  }
1154
1131
 
1155
1132
  if(user.peers[topic].peerConnection.connectionState === 'connected') {
@@ -1187,6 +1164,7 @@
1187
1164
  });
1188
1165
  if(chatMessaging.chatState) {
1189
1166
  callController.shouldReconnectTopic(userId, topic, mediaType, direction);
1167
+ //callController.removeConnectionQualityInterval(userId, topic);
1190
1168
  }
1191
1169
  // } else {
1192
1170
  // setTimeout(function () {
@@ -1226,9 +1204,11 @@
1226
1204
  topic: topic
1227
1205
  }, function (result) {
1228
1206
  if (result.done === 'TRUE') {
1207
+ clearInterval(callUsers[userId].topicMetaData[topic].interval)
1229
1208
  callController.removeTopic(userId, topic);
1230
1209
  callController.createTopic(userId, topic, mediaType, direction, userId === 'screenShare');
1231
1210
  } else if (result.done === 'SKIP') {
1211
+ clearInterval(callUsers[userId].topicMetaData[topic].interval)
1232
1212
  callController.removeTopic(userId, topic);
1233
1213
  callController.createTopic(userId, topic, mediaType, direction, userId === 'screenShare');
1234
1214
  //generateAndSendSdpOffers(currentCallParams, [topicName]);
@@ -1627,6 +1607,12 @@
1627
1607
  }
1628
1608
  consoleLogging && console.log("[SDK][handleProcessSdpAnswer]", jsonMessage, jsonMessage.topic)
1629
1609
  startMedia(callUsers[userId].htmlElements[jsonMessage.topic]);
1610
+ if(userId === 'screenShare') {
1611
+ restartMediaOnKeyFrame("screenShare", 2000);
1612
+ restartMediaOnKeyFrame("screenShare", 4000);
1613
+ restartMediaOnKeyFrame("screenShare", 8000);
1614
+ restartMediaOnKeyFrame("screenShare", 12000);
1615
+ }
1630
1616
  });
1631
1617
  },
1632
1618
 
@@ -1699,45 +1685,48 @@
1699
1685
  currentCallId = null;
1700
1686
  },
1701
1687
 
1702
- removeStreamFromWebRTC = function (RTCStream) {
1703
- var callParentDiv = document.getElementById(callDivId);
1688
+ /*
1689
+ removeStreamFromWebRTC = function (RTCStream) {
1690
+ var callParentDiv = document.getElementById(callDivId);
1704
1691
 
1705
- if (uiRemoteMedias.hasOwnProperty(RTCStream)) {
1706
- const stream = uiRemoteMedias[RTCStream].srcObject;
1707
- if (!!stream) {
1708
- const tracks = stream.getTracks();
1692
+ if (uiRemoteMedias.hasOwnProperty(RTCStream)) {
1693
+ const stream = uiRemoteMedias[RTCStream].srcObject;
1694
+ if (!!stream) {
1695
+ const tracks = stream.getTracks();
1709
1696
 
1710
- if (!!tracks) {
1711
- tracks.forEach(function (track) {
1712
- track.stop();
1713
- });
1714
- }
1697
+ if (!!tracks) {
1698
+ tracks.forEach(function (track) {
1699
+ track.stop();
1700
+ });
1701
+ }
1715
1702
 
1716
- uiRemoteMedias[RTCStream].srcObject = null;
1717
- }
1703
+ uiRemoteMedias[RTCStream].srcObject = null;
1704
+ }
1718
1705
 
1719
- uiRemoteMedias[RTCStream].remove();
1720
- delete (uiRemoteMedias[RTCStream]);
1721
- }
1722
- },
1706
+ uiRemoteMedias[RTCStream].remove();
1707
+ delete (uiRemoteMedias[RTCStream]);
1708
+ }
1709
+ },
1723
1710
 
1724
- removeFromCallUI = function (topic) {
1725
- var videoElement = 'Vi-' + topic;
1726
- var audioElement = 'Vo-' + topic;
1727
1711
 
1728
- if (topic.length > 0 && uiRemoteMedias.hasOwnProperty(videoElement)) {
1729
- removeStreamFromWebRTC(videoElement);
1730
- }
1712
+ removeFromCallUI = function (topic) {
1713
+ var videoElement = 'Vi-' + topic;
1714
+ var audioElement = 'Vo-' + topic;
1731
1715
 
1732
- if (topic.length > 0 && uiRemoteMedias.hasOwnProperty(audioElement)) {
1733
- removeStreamFromWebRTC(audioElement);
1734
- }
1735
- },
1716
+ if (topic.length > 0 && uiRemoteMedias.hasOwnProperty(videoElement)) {
1717
+ removeStreamFromWebRTC(videoElement);
1718
+ }
1719
+
1720
+ if (topic.length > 0 && uiRemoteMedias.hasOwnProperty(audioElement)) {
1721
+ removeStreamFromWebRTC(audioElement);
1722
+ }
1723
+ },
1724
+ */
1736
1725
 
1737
1726
  restartMediaOnKeyFrame = function (userId, timeout) {
1738
1727
  setTimeout(function () {
1739
- if(typeof callUsers[chatMessaging.userInfo.id] !== "undefined" && callUsers[chatMessaging.userInfo.id])
1740
- restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
1728
+ if(typeof callUsers[userId] !== "undefined" && callUsers[userId])
1729
+ restartMedia(callUsers[userId].videoTopicName);
1741
1730
  }, timeout);
1742
1731
  };
1743
1732
 
@@ -1764,10 +1753,22 @@
1764
1753
  break;
1765
1754
 
1766
1755
  case 'GET_KEY_FRAME':
1767
- restartMediaOnKeyFrame(chatMessaging.userInfo.id, 2000);
1768
- restartMediaOnKeyFrame(chatMessaging.userInfo.id, 4000);
1769
- restartMediaOnKeyFrame(chatMessaging.userInfo.id, 8000);
1770
- restartMediaOnKeyFrame(chatMessaging.userInfo.id, 12000);
1756
+ if(callUsers && callUsers[chatMessaging.userInfo.id] && callUsers[chatMessaging.userInfo.id].video) {
1757
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 2000);
1758
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 4000);
1759
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 8000);
1760
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 12000);
1761
+ }
1762
+ if(callUsers && callUsers['screenShare']
1763
+ && callUsers['screenShare'].video
1764
+ && screenShareState.started
1765
+ && screenShareState.imOwner) {
1766
+ restartMediaOnKeyFrame('screenShare', 2000);
1767
+ restartMediaOnKeyFrame('screenShare', 4000);
1768
+ restartMediaOnKeyFrame('screenShare', 8000);
1769
+ restartMediaOnKeyFrame('screenShare', 12000);
1770
+ }
1771
+
1771
1772
  /* setTimeout(function () {
1772
1773
  if(typeof callUsers[chatMessaging.userInfo.id] === "undefined" || !callUsers[chatMessaging.userInfo.id])
1773
1774
  restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
@@ -2046,8 +2047,9 @@
2046
2047
  type: 'CALL_PARTICIPANT_CONNECTED',
2047
2048
  result: messageContent
2048
2049
  });
2049
-
2050
- restartMedia(callTopics['sendVideoTopic']);
2050
+ //callTopics['sendVideoTopic']
2051
+ //restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
2052
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 100)
2051
2053
 
2052
2054
  break;
2053
2055
 
@@ -2126,8 +2128,8 @@
2126
2128
  result: messageContent
2127
2129
  });
2128
2130
 
2129
- restartMedia(callTopics['sendVideoTopic']);
2130
-
2131
+ //restartMedia(callTopics['sendVideoTopic']);
2132
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 100)
2131
2133
  break;
2132
2134
 
2133
2135
  /**
@@ -2357,8 +2359,8 @@
2357
2359
  result: messageContent
2358
2360
  });
2359
2361
 
2360
- restartMedia(callTopics['sendVideoTopic']);
2361
-
2362
+ //restartMedia(callTopics['sendVideoTopic']);
2363
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 100)
2362
2364
  break;
2363
2365
 
2364
2366
  /**
@@ -2454,8 +2456,8 @@
2454
2456
  result: messageContent
2455
2457
  });
2456
2458
 
2457
- restartMedia(callTopics['sendVideoTopic']);
2458
-
2459
+ //restartMedia(callTopics['sendVideoTopic']);
2460
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 100)
2459
2461
  break;
2460
2462
  }
2461
2463
  }
@@ -2747,7 +2749,8 @@
2747
2749
 
2748
2750
  return chatMessaging.sendMessage(recordCallData, {
2749
2751
  onResult: function (result) {
2750
- restartMedia(callTopics['sendVideoTopic']);
2752
+ //restartMedia(callTopics['sendVideoTopic']);
2753
+ restartMediaOnKeyFrame(chatMessaging.userInfo.id, 100)
2751
2754
  callback && callback(result);
2752
2755
  }
2753
2756
  });
package/config.js DELETED
@@ -1,59 +0,0 @@
1
- var CONFIG = {
2
- // token: '1cfce37b60d4421db870e67dcfe407d9', // gameBOT
3
- // token: '567179f126d84277b8dced22599e0b82', // takiBOT
4
- // token: '1a9d91ccb4d5431b89dd74f7e0bb417b', // talkyBOT
5
- // token: 'd10237d19ad24ba089f66bdfe3de9974', // Clasor
6
- // token: "b135febd870746f88032df84dfb01c85", // Clasor Test BOT
7
- token: 'b45fa3d386f54e34b82d81a11bc27e90',
8
-
9
- // Permenant Integration Tokens
10
- // token: "3dd6895c8dc64f93bcd43b58dcc2aab3", // Masoud Amjadi
11
- // token: "9c627a9125d04ebf8455bf57bb33d2a9", // Pooria Pahlevani
12
- // token: "f6464d4e0f044314b1a668f90287ba26", // Nadia Anvari
13
- // token: "99506f7c32c849a9a6e2a954303b81ee", // Farhad Kheirkhah
14
- // token: "979aa5de03934c73a5c6c855bd80cb04", // Mahyar Zhiani
15
- // token: "a47c9016c8354236abc01395093bed5c", // Ahmad Sajadi
16
- // token: "d3114ed2fd2a49b4a0a386e727c9e5fa", // Saba Safavi
17
- // token: "872110b9c6944eda9bc98ef2a68dcf50", // Leila Nemati
18
-
19
- // ActiveMQ Connection config
20
- // queueHost: "10.56.16.25",
21
- // queuePort: "61613",
22
- // queueUsername: "root",
23
- // queuePassword: "zalzalak",
24
- // queueReceive: "queue-in-amjadi-stomp",
25
- // queueSend: "queue-out-amjadi-stomp",
26
-
27
- // Neshan Map Api Token
28
- mapApiKey: '8b77db18704aa646ee5aaea13e7370f4f88b9e8c',
29
-
30
- // Main Server
31
- main: {
32
- socketAddress: 'wss://msg.pod.ir/ws',
33
- ssoHost: 'https://accounts.pod.ir',
34
- platformHost: 'https://api.pod.ir/srv/core',
35
- fileServer: 'https://core.pod.ir',
36
- podSpaceFileServer: 'https://podspace.podland.ir',
37
- serverName: 'chat-server'
38
- },
39
-
40
- // Sand Box Server
41
- sandbox: {
42
- socketAddress: "wss://chat-sandbox.pod.ir/ws",
43
- ssoHost: "https://accounts.pod.ir",
44
- platformHost: "https://sandbox.pod.ir:8043/srv/basic-platform",
45
- fileServer: 'https://core.pod.ir',
46
- podSpaceFileServer: 'http://sandbox.podspace.ir:8080',
47
- serverName: "chat-server"
48
- },
49
-
50
- // Integration Server
51
- integration: {
52
- socketAddress: "ws://172.16.110.235:8003/ws",
53
- ssoHost: "http://172.16.110.76",
54
- platformHost: "http://172.16.110.235:8003/srv/bptest-core",
55
- fileServer: 'https://core.pod.ir',
56
- podSpaceFileServer: 'http://172.16.110.61:8780/podspace',
57
- serverName: "chatlocal"
58
- }
59
- }