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.
@@ -30,7 +30,7 @@
30
30
  <script type="text/javascript">
31
31
  // Developement
32
32
  var PodChat = window.POD.Chat;
33
- var env = 'main'; // main | sandbox | integration
33
+ var env = 'sandbox'; // main | sandbox | integration
34
34
 
35
35
  var params = {
36
36
  appId: new Date().getTime(),
@@ -1906,6 +1906,22 @@ Thread: <input type="text" id="threadInput" autocomplete="on" width="500">
1906
1906
  <hr>
1907
1907
  <br>
1908
1908
 
1909
+ <form>
1910
+ <fieldset>
1911
+ <legend>Admin thread participant</legend>
1912
+ <label for="apThread">Thread Id</label>
1913
+ <input type="text" name="adminThreadParticipantThreadId" id="adminThreadParticipantThreadId" >
1914
+ <br>
1915
+ <label for="apList">User Id</label>
1916
+ <input type="text" name="adminThreadParticipantUserId" id="adminThreadParticipantUserId" placeholder="UserId">
1917
+ <button type="button" name="button" id="adminThreadParticipantBtn">Make admin</button>
1918
+ </fieldset>
1919
+ </form>
1920
+
1921
+ <br>
1922
+ <hr>
1923
+ <br>
1924
+
1909
1925
  <form>
1910
1926
  <fieldset>
1911
1927
  <legend>Send Text Message</legend>
@@ -3165,7 +3181,36 @@ Thread: <input type="text" id="threadInput" autocomplete="on" width="500">
3165
3181
  threadId: Number(threadId),
3166
3182
  messageIds: messageIds instanceof Array ? messageIds : [ messageIds ],
3167
3183
  }, {})
3168
- })
3184
+ });
3185
+
3186
+ document.getElementById("adminThreadParticipantBtn").addEventListener("click", function (event){
3187
+ event.preventDefault();
3188
+ var userId = document.getElementById("adminThreadParticipantUserId").value;
3189
+ var threadId = document.getElementById("adminThreadParticipantThreadId").value;
3190
+ var rolesList = [
3191
+ 'post_channel_message',
3192
+ 'edit_message_of_others',
3193
+ 'delete_message_of_others',
3194
+ 'add_new_user',
3195
+ 'remove_user',
3196
+ 'thread_admin',
3197
+ 'add_rule_to_user',
3198
+ 'remove_role_from_user',
3199
+ 'edit_thread',
3200
+ 'read_thread',
3201
+ 'ownership'
3202
+ ];
3203
+ console.log("roles list: ", rolesList)
3204
+ chatAgent.setAdmin({
3205
+ threadId: threadId,
3206
+ admins: [{
3207
+ userId: userId,
3208
+ roles: rolesList
3209
+ }],
3210
+ }, function (result) {
3211
+ console.log("[HTML][chatAgent.setAdmin][result]", result);
3212
+ })
3213
+ });
3169
3214
  </script>
3170
3215
 
3171
3216
  </html>
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "podchat-browser",
3
- "version": "11.4.3",
3
+ "version": "12.1.0",
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.4.3.js",
8
+ "bundle": "browserify browser-bundling.js -o ./dist/podchat-12.1.0.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.4.3"
12
+ "version:release": "npm version 12.1.0"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
@@ -107,6 +107,7 @@
107
107
  TERMINATE_CALL: 96,
108
108
  MUTE_CALL_PARTICIPANT: 97,
109
109
  UNMUTE_CALL_PARTICIPANT: 98,
110
+ CANCEL_GROUP_CALL: 99, //TODO: not implemented
110
111
  LOGOUT: 100,
111
112
  LOCATION_PING: 101,
112
113
  CLOSE_THREAD: 102,
@@ -189,6 +190,7 @@
189
190
  : 180,
190
191
  currentCallParams = {},
191
192
  currentCallId = null,
193
+ newCallId = null,
192
194
  shouldReconnectCallTimeout = null,
193
195
  callTopics = {},
194
196
  callMetaDataTypes = {
@@ -825,8 +827,17 @@
825
827
  options[(direction === 'send' ? 'localVideo' : 'remoteVideo')] = callUsers[userId].htmlElements[topic];
826
828
 
827
829
  if(direction === 'send' && mediaType === 'video' && shareScreen) {
828
- navigator.mediaDevices.getDisplayMedia().then(function (result) {
829
- options.videoStream = result;
830
+ navigator.mediaDevices.getDisplayMedia().then(function (stream) {
831
+ stream.getVideoTracks()[0].addEventListener("ended", function (event) { // Click on browser UI stop sharing button
832
+ //callStateController.removeScreenShareFromCall()
833
+ if(callUsers['screenShare'] && callUsers['screenShare'].peers[topic]){
834
+ //console.log('event screenShare', currentCallId);
835
+ currentModuleInstance.endScreenShare({
836
+ callId: currentCallId
837
+ });
838
+ }
839
+ })
840
+ options.videoStream = stream;
830
841
  options.sendSource = 'screen';
831
842
  // options[(direction === 'send' ? 'localVideo' : 'remoteVideo')] = uiRemoteMedias[topic];
832
843
  resolve(options);
@@ -1201,7 +1212,9 @@
1201
1212
  },
1202
1213
  removeAllCallParticipants: function () {
1203
1214
  var removeAllUsersPromise = new Promise(function (resolve, reject) {
1215
+ var index = 0;
1204
1216
  for (var i in callUsers) {
1217
+ index++;
1205
1218
  var user = callUsers[i];
1206
1219
  if (user) {
1207
1220
  if(user.videoTopicName && user.peers[user.videoTopicName]) {
@@ -1228,7 +1241,8 @@
1228
1241
  callUsers[i] = null;
1229
1242
  }
1230
1243
 
1231
- resolve()
1244
+ if(index === Object.keys(callUsers).length)
1245
+ resolve();
1232
1246
  }, 200);
1233
1247
  }
1234
1248
  }
@@ -1857,7 +1871,10 @@
1857
1871
  result: messageContent
1858
1872
  });
1859
1873
 
1860
- currentCallId = messageContent.callId;
1874
+ if(!currentCallId)
1875
+ currentCallId = messageContent.callId;
1876
+ else
1877
+ newCallId = messageContent.callId;
1861
1878
  } else {
1862
1879
  chatEvents.fireEvent('callEvents', {
1863
1880
  type: 'PARTNER_RECEIVED_YOUR_CALL',
@@ -1950,10 +1967,11 @@
1950
1967
 
1951
1968
  chatEvents.fireEvent('callEvents', {
1952
1969
  type: 'CALL_ENDED',
1953
- result: messageContent
1970
+ callId: threadId
1954
1971
  });
1955
1972
 
1956
- callStop();
1973
+ if(threadId === currentCallId)
1974
+ callStop();
1957
1975
 
1958
1976
  break;
1959
1977
 
@@ -2188,17 +2206,6 @@
2188
2206
  messageContent[i].sendTopic,
2189
2207
  'mute'
2190
2208
  );
2191
- /*if(callUsers[messageContent[i].userId]) {
2192
- callUsers[messageContent[i].userId].mute = false;
2193
- callUsers[messageContent[i].userId].audioTopicName = 'Vo-' + messageContent[i].sendTopic;
2194
-
2195
- var user = callUsers[messageContent[i].userId];
2196
- callStateController.appendUserToCallDiv(messageContent[i].userId, callStateController.generateHTMLElements(messageContent[i].userId));
2197
- setTimeout(function () {
2198
- callStateController.createTopic(messageContent[i].userId, user.audioTopicName, 'audio', 'receive');
2199
-
2200
- })
2201
- }*/
2202
2209
  }
2203
2210
  }
2204
2211
  }
@@ -2236,7 +2243,12 @@
2236
2243
  result: messageContent
2237
2244
  });
2238
2245
 
2239
- currentCallId = messageContent.callId;
2246
+ if(!currentCallId)
2247
+ currentCallId = messageContent.callId;
2248
+ else
2249
+ newCallId = messageContent.callId;
2250
+
2251
+ //currentCallId = messageContent.callId;
2240
2252
 
2241
2253
  break;
2242
2254
 
package/src/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ 'use strict';
2
2
 
3
3
  (function () {
4
4
  /*
@@ -13608,12 +13608,11 @@
13608
13608
  var str = ''
13609
13609
  , universalBOM = "\uFEFF";
13610
13610
 
13611
- console.log(result);
13612
- str += "تاریخ " + ',';
13613
- str += " ساعت " + ',';
13614
- str += "نام فرستنده" + ',';
13615
- str += "نام کاربری فرستنده" + ',';
13616
- str += "متن پیام" + ',';
13611
+ str += "\u{62A}\u{627}\u{631}\u{6CC}\u{62E} " + ','; //tarikh
13612
+ str += " \u{633}\u{627}\u{639}\u{62A} " + ','; //saat
13613
+ str += "\u{646}\u{627}\u{645} \u{641}\u{631}\u{633}\u{62A}\u{646}\u{62F}\u{647}" + ',';//name ferestande
13614
+ 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
13615
+ str += "\u{645}\u{62A}\u{646} \u{67E}\u{6CC}\u{627}\u{645}" + ',';//matne payam
13617
13616
  str += '\r\n';
13618
13617
  var line = '', radif = 1;
13619
13618
  for (var i = 0; i < result.length; i++) {