podchat-browser 12.7.2-snapshot.2 → 12.7.2-snapshot.21
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/dist/node/call.module.js +615 -403
- package/dist/node/chat.js +246 -80
- package/dist/node/lib/constants.js +1 -1
- package/dist/node/lib/errorHandler.js +4 -0
- package/dist/node/lib/store/eventEmitter.js +24 -0
- package/dist/node/lib/store/index.js +16 -0
- package/dist/node/lib/store/threads.js +121 -0
- package/dist/node/messaging.module.js +28 -9
- package/dist/podchat-browser-bundle.js +782 -239
- package/examples/index.html +7 -3
- package/package.json +2 -2
- package/src/call.module.js +228 -108
- package/src/chat.js +371 -288
- package/src/lib/constants.js +1 -1
- package/src/lib/errorHandler.js +4 -0
- package/src/lib/store/eventEmitter.js +16 -0
- package/src/lib/store/index.js +9 -0
- package/src/lib/store/threads.js +99 -0
- package/src/messaging.module.js +22 -6
package/examples/index.html
CHANGED
|
@@ -1764,20 +1764,24 @@ Thread: <input type="text" id="threadInput" autocomplete="on" width="500">
|
|
|
1764
1764
|
<br>
|
|
1765
1765
|
<a class="btn" href="#" onclick="getContacts({
|
|
1766
1766
|
count:document.getElementById('g-p2p-count').value,
|
|
1767
|
-
offset: document.getElementById('g-p2p-off').value
|
|
1767
|
+
offset: document.getElementById('g-p2p-off').value,
|
|
1768
|
+
// coreUserId: 179267
|
|
1768
1769
|
})">Get Contacts</a>
|
|
1769
1770
|
<a class="btn" href="#" onclick="getThreads({
|
|
1770
1771
|
count:document.getElementById('g-p2p-count').value,
|
|
1771
1772
|
offset: document.getElementById('g-p2p-off').value,
|
|
1772
1773
|
// fromTime: 1651918475566 ,
|
|
1773
1774
|
// toTime: new Date().getTime(),
|
|
1774
|
-
// new: true
|
|
1775
|
+
// new: true,
|
|
1776
|
+
// isGroup: true,
|
|
1777
|
+
// type: 0//undefined OR integer: NORMAL: 0x0, OWNER_GROUP: 0x1, PUBLIC_GROUP: 0x2, CHANNEL_GROUP: 0x4, CHANNEL: 0x8, NOTIFICATION_CHANNEL: 0x10, PUBLIC_THREAD: 0x20, PUBLIC_CHANNEL: 0x40, SELF: 0x80
|
|
1775
1778
|
})">Get Threads</a>
|
|
1776
1779
|
<a class="btn" href="#" onclick="getHistory({
|
|
1777
1780
|
// fromTimeFull: 1557830885624256000,
|
|
1778
1781
|
// toTimeFull: 1558247572310448000,
|
|
1779
1782
|
count:document.getElementById('g-p2p-count').value,
|
|
1780
1783
|
offset: document.getElementById('g-p2p-off').value,
|
|
1784
|
+
// onlyNewMessages: true,
|
|
1781
1785
|
threadId: document.getElementById('g-p2p').value});">Get History</a>
|
|
1782
1786
|
<a class="btn" href="#" onclick="getThreadParticipants(document.getElementById('g-p2p').value)">Get Thread
|
|
1783
1787
|
Participants</a>
|
|
@@ -3234,7 +3238,7 @@ Thread: <input type="text" id="threadInput" autocomplete="on" width="500">
|
|
|
3234
3238
|
autoStartDownload: true,
|
|
3235
3239
|
responseType: 'link',
|
|
3236
3240
|
wantedCount: 10000,
|
|
3237
|
-
stepCount:
|
|
3241
|
+
stepCount: 500
|
|
3238
3242
|
}, result => {
|
|
3239
3243
|
console.log(result);
|
|
3240
3244
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podchat-browser",
|
|
3
|
-
"version": "12.7.2-snapshot.
|
|
3
|
+
"version": "12.7.2-snapshot.21",
|
|
4
4
|
"description": "Javascript SDK to use POD's Chat Service - Browser Only",
|
|
5
5
|
"main": "./dist/node/chat.js",
|
|
6
6
|
"scripts": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"faker": "^5.5.3",
|
|
52
52
|
"kurento-utils": "^6.16.0",
|
|
53
53
|
"node-rsa": "^1.1.1",
|
|
54
|
-
"podasync-ws-only": "^2.7.
|
|
54
|
+
"podasync-ws-only": "^2.7.11",
|
|
55
55
|
"query-string": "^6.8.1",
|
|
56
56
|
"webrtc-adapter": "^8.0.0"
|
|
57
57
|
},
|
package/src/call.module.js
CHANGED
|
@@ -54,6 +54,8 @@ function ChatCall(params) {
|
|
|
54
54
|
? params.callOptions.callVideo.minHeight
|
|
55
55
|
: 180,
|
|
56
56
|
currentCallParams = {},
|
|
57
|
+
requestedCallId = null,
|
|
58
|
+
acceptedCallId = null,
|
|
57
59
|
currentCallId = null,
|
|
58
60
|
latestCallRequestId = null,
|
|
59
61
|
//shouldReconnectCallTimeout = null,
|
|
@@ -79,8 +81,25 @@ function ChatCall(params) {
|
|
|
79
81
|
callRequestReceived: false,
|
|
80
82
|
callEstablishedInMySide: false,
|
|
81
83
|
callRequestTimeout: null,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
|
|
85
|
+
iRequestedCall: false,
|
|
86
|
+
iAcceptedCall: false,
|
|
87
|
+
|
|
88
|
+
canProcessStartCall: function (callId) {
|
|
89
|
+
consoleLogging && console.log(
|
|
90
|
+
"[SDK] canProcessStartCall:",
|
|
91
|
+
{callId},
|
|
92
|
+
{acceptedCallId},
|
|
93
|
+
callRequestController.iAcceptedCall,
|
|
94
|
+
callRequestController.iAcceptedCall && acceptedCallId == callId
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
if(callRequestController.iAcceptedCall && acceptedCallId == callId
|
|
98
|
+
|| callRequestController.iRequestedCall && requestedCallId == callId)
|
|
99
|
+
return true;
|
|
100
|
+
|
|
101
|
+
return false;
|
|
102
|
+
//callRequestController.callRequestReceived && callRequestController.callEstablishedInMySide;
|
|
84
103
|
},
|
|
85
104
|
cameraPaused: true
|
|
86
105
|
},
|
|
@@ -600,7 +619,7 @@ function ChatCall(params) {
|
|
|
600
619
|
manager.watchAudioLevel();
|
|
601
620
|
}
|
|
602
621
|
config.state = peerStates.CONNECTED;
|
|
603
|
-
callRequestController.callEstablishedInMySide = true;
|
|
622
|
+
// callRequestController.callEstablishedInMySide = true;
|
|
604
623
|
chatEvents.fireEvent('callEvents', {
|
|
605
624
|
type: 'CALL_STATUS',
|
|
606
625
|
errorCode: 7000,
|
|
@@ -1335,9 +1354,9 @@ function ChatCall(params) {
|
|
|
1335
1354
|
token: token
|
|
1336
1355
|
};
|
|
1337
1356
|
|
|
1338
|
-
if (!callRequestController.callEstablishedInMySide) {
|
|
1339
|
-
|
|
1340
|
-
}
|
|
1357
|
+
// if (!callRequestController.callEstablishedInMySide) {
|
|
1358
|
+
// return;
|
|
1359
|
+
// }
|
|
1341
1360
|
|
|
1342
1361
|
if (params) {
|
|
1343
1362
|
if (typeof +params.callId === 'number' && params.callId > 0) {
|
|
@@ -1706,7 +1725,7 @@ function ChatCall(params) {
|
|
|
1706
1725
|
}
|
|
1707
1726
|
},
|
|
1708
1727
|
maybeReconnectAllTopics: function (){
|
|
1709
|
-
if(!callUsers || !Object.keys(callUsers).length
|
|
1728
|
+
if(!callUsers || !Object.keys(callUsers).length) //|| !callRequestController.callEstablishedInMySide
|
|
1710
1729
|
return;
|
|
1711
1730
|
|
|
1712
1731
|
for(let i in callUsers) {
|
|
@@ -2261,37 +2280,49 @@ function ChatCall(params) {
|
|
|
2261
2280
|
},
|
|
2262
2281
|
*/
|
|
2263
2282
|
|
|
2264
|
-
callStop = function (
|
|
2283
|
+
callStop = function (resetCurrentCallId = true, resetCameraPaused = true) {
|
|
2265
2284
|
|
|
2266
|
-
|
|
2285
|
+
return new Promise((resolve, reject) => {
|
|
2286
|
+
// callTopicHealthChecker.stopTopicsHealthCheck();
|
|
2267
2287
|
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2288
|
+
deviceManager.mediaStreams().stopVideoInput();
|
|
2289
|
+
deviceManager.mediaStreams().stopAudioInput();
|
|
2290
|
+
deviceManager.mediaStreams().stopScreenShareInput();
|
|
2271
2291
|
|
|
2272
|
-
|
|
2292
|
+
callStateController.removeAllCallParticipants();
|
|
2273
2293
|
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2294
|
+
if (callStopQueue.callStarted) {
|
|
2295
|
+
sendCallMessage({
|
|
2296
|
+
id: 'CLOSE'
|
|
2297
|
+
}, null, {});
|
|
2298
|
+
callStopQueue.callStarted = false;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
if(resetCameraPaused)
|
|
2302
|
+
callRequestController.cameraPaused = false;
|
|
2303
|
+
|
|
2304
|
+
// callRequestController.iRequestedCall = false;
|
|
2305
|
+
// callRequestController.iAcceptedCall = false;
|
|
2306
|
+
//acceptedCallId = null;
|
|
2307
|
+
//requestedCallId = null;
|
|
2308
|
+
|
|
2309
|
+
// callRequestController.callEstablishedInMySide = false;
|
|
2310
|
+
// callRequestController.callRequestReceived = false;
|
|
2311
|
+
clearTimeout(callRequestController.callRequestTimeout);
|
|
2280
2312
|
|
|
2281
|
-
|
|
2282
|
-
callRequestController.
|
|
2313
|
+
// if(resetCallOwner)
|
|
2314
|
+
// callRequestController.imCallOwner = false;
|
|
2283
2315
|
|
|
2284
|
-
|
|
2285
|
-
callRequestController.callRequestReceived = false;
|
|
2286
|
-
clearTimeout(callRequestController.callRequestTimeout);
|
|
2316
|
+
currentCallParams = {};
|
|
2287
2317
|
|
|
2288
|
-
|
|
2289
|
-
|
|
2318
|
+
if(resetCurrentCallId)
|
|
2319
|
+
currentCallId = null;
|
|
2290
2320
|
|
|
2291
|
-
currentCallParams = {};
|
|
2292
2321
|
|
|
2293
|
-
|
|
2294
|
-
|
|
2322
|
+
setTimeout(()=>{
|
|
2323
|
+
resolve(true)
|
|
2324
|
+
}, 2000);
|
|
2325
|
+
})
|
|
2295
2326
|
},
|
|
2296
2327
|
|
|
2297
2328
|
restartMediaOnKeyFrame = function (userId, timeouts) {
|
|
@@ -2634,6 +2665,7 @@ function ChatCall(params) {
|
|
|
2634
2665
|
chatMessageVOTypes.END_RECORD_CALL,
|
|
2635
2666
|
chatMessageVOTypes.TERMINATE_CALL,
|
|
2636
2667
|
chatMessageVOTypes.CALL_STICKER_SYSTEM_MESSAGE,
|
|
2668
|
+
chatMessageVOTypes.CALL_RECORDING_FAILED,
|
|
2637
2669
|
// chatMessageVOTypes.END_CALL
|
|
2638
2670
|
];
|
|
2639
2671
|
|
|
@@ -2655,7 +2687,7 @@ function ChatCall(params) {
|
|
|
2655
2687
|
* Type 70 Send Call Request
|
|
2656
2688
|
*/
|
|
2657
2689
|
case chatMessageVOTypes.CALL_REQUEST:
|
|
2658
|
-
callRequestController.callRequestReceived = true;
|
|
2690
|
+
// callRequestController.callRequestReceived = true;
|
|
2659
2691
|
callReceived({
|
|
2660
2692
|
callId: messageContent.callId
|
|
2661
2693
|
}, function (r) {
|
|
@@ -2675,7 +2707,6 @@ function ChatCall(params) {
|
|
|
2675
2707
|
// if(!currentCallId ) {
|
|
2676
2708
|
latestCallRequestId = messageContent.callId;
|
|
2677
2709
|
// }
|
|
2678
|
-
|
|
2679
2710
|
} else {
|
|
2680
2711
|
chatEvents.fireEvent('callEvents', {
|
|
2681
2712
|
type: 'PARTNER_RECEIVED_YOUR_CALL',
|
|
@@ -2744,7 +2775,7 @@ function ChatCall(params) {
|
|
|
2744
2775
|
* Type 74 Start Call (Start sender and receivers)
|
|
2745
2776
|
*/
|
|
2746
2777
|
case chatMessageVOTypes.START_CALL:
|
|
2747
|
-
if(!callRequestController.
|
|
2778
|
+
if(!callRequestController.canProcessStartCall(threadId)) {
|
|
2748
2779
|
chatEvents.fireEvent('callEvents', {
|
|
2749
2780
|
type: 'CALL_STARTED_ELSEWHERE',
|
|
2750
2781
|
message: 'Call already started somewhere else..., aborting...'
|
|
@@ -2752,50 +2783,16 @@ function ChatCall(params) {
|
|
|
2752
2783
|
return;
|
|
2753
2784
|
}
|
|
2754
2785
|
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
messageContent.callId = threadId;
|
|
2763
|
-
chatEvents.fireEvent('callEvents', {
|
|
2764
|
-
type: 'CALL_STARTED',
|
|
2765
|
-
result: messageContent
|
|
2766
|
-
});
|
|
2767
|
-
|
|
2768
|
-
if (typeof messageContent === 'object'
|
|
2769
|
-
&& messageContent.hasOwnProperty('chatDataDto')
|
|
2770
|
-
&& !!messageContent.chatDataDto.kurentoAddress) {
|
|
2771
|
-
|
|
2772
|
-
callServerController.setServers(messageContent.chatDataDto.kurentoAddress.split(','));
|
|
2773
|
-
|
|
2774
|
-
startCallWebRTCFunctions({
|
|
2775
|
-
video: messageContent.clientDTO.video,
|
|
2776
|
-
mute: messageContent.clientDTO.mute,
|
|
2777
|
-
sendingTopic: messageContent.clientDTO.topicSend,
|
|
2778
|
-
receiveTopic: messageContent.clientDTO.topicReceive,
|
|
2779
|
-
screenShare: messageContent.chatDataDto.screenShare,
|
|
2780
|
-
brokerAddress: messageContent.chatDataDto.brokerAddressWeb,
|
|
2781
|
-
turnAddress: messageContent.chatDataDto.turnAddress,
|
|
2782
|
-
internalTurnAddress: messageContent.chatDataDto.internalTurnAddress,
|
|
2783
|
-
selfData: messageContent.clientDTO,
|
|
2784
|
-
clientsList: messageContent.otherClientDtoList,
|
|
2785
|
-
screenShareOwner: +messageContent.chatDataDto.screenShareUser,
|
|
2786
|
-
recordingOwner: +messageContent.chatDataDto.recordingUser
|
|
2787
|
-
}, function (callDivs) {
|
|
2788
|
-
chatEvents.fireEvent('callEvents', {
|
|
2789
|
-
type: 'CALL_DIVS',
|
|
2790
|
-
result: callDivs
|
|
2791
|
-
});
|
|
2792
|
-
});
|
|
2786
|
+
if(currentCallId) {
|
|
2787
|
+
endCall({callId: currentCallId});
|
|
2788
|
+
callStop( true, false);
|
|
2789
|
+
setTimeout(()=>{
|
|
2790
|
+
currentCallId = threadId;
|
|
2791
|
+
processChatStartCallEvent(type, messageContent, contentCount, threadId, uniqueId);
|
|
2792
|
+
}, 5000);
|
|
2793
2793
|
} else {
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
message: 'Chat Data DTO is not present!',
|
|
2797
|
-
environmentDetails: getSDKCallDetails()
|
|
2798
|
-
});
|
|
2794
|
+
currentCallId = threadId;
|
|
2795
|
+
processChatStartCallEvent(type, messageContent, contentCount, threadId, uniqueId);
|
|
2799
2796
|
}
|
|
2800
2797
|
|
|
2801
2798
|
break;
|
|
@@ -2897,7 +2894,7 @@ function ChatCall(params) {
|
|
|
2897
2894
|
* Type 91 Send Group Call Request
|
|
2898
2895
|
*/
|
|
2899
2896
|
case chatMessageVOTypes.GROUP_CALL_REQUEST:
|
|
2900
|
-
callRequestController.callRequestReceived = true;
|
|
2897
|
+
// callRequestController.callRequestReceived = true;
|
|
2901
2898
|
callReceived({
|
|
2902
2899
|
callId: messageContent.callId
|
|
2903
2900
|
}, function (r) {});
|
|
@@ -2999,15 +2996,15 @@ function ChatCall(params) {
|
|
|
2999
2996
|
if(!correctedData.mute) {
|
|
3000
2997
|
callStateController.startParticipantAudio(correctedData.userId);
|
|
3001
2998
|
}
|
|
2999
|
+
|
|
3000
|
+
chatEvents.fireEvent('callEvents', {
|
|
3001
|
+
type: 'CALL_DIVS',
|
|
3002
|
+
result: generateCallUIList()
|
|
3003
|
+
});
|
|
3002
3004
|
}, 500)
|
|
3003
3005
|
}
|
|
3004
3006
|
}
|
|
3005
3007
|
|
|
3006
|
-
chatEvents.fireEvent('callEvents', {
|
|
3007
|
-
type: 'CALL_DIVS',
|
|
3008
|
-
result: generateCallUIList()
|
|
3009
|
-
});
|
|
3010
|
-
|
|
3011
3008
|
chatEvents.fireEvent('callEvents', {
|
|
3012
3009
|
type: 'CALL_PARTICIPANT_JOINED',
|
|
3013
3010
|
result: messageContent
|
|
@@ -3187,7 +3184,9 @@ function ChatCall(params) {
|
|
|
3187
3184
|
* Type 111 Kafka Call Session Created
|
|
3188
3185
|
*/
|
|
3189
3186
|
case chatMessageVOTypes.CALL_SESSION_CREATED:
|
|
3190
|
-
if(!callRequestController.callEstablishedInMySide)
|
|
3187
|
+
// if(!callRequestController.callEstablishedInMySide)
|
|
3188
|
+
// return;
|
|
3189
|
+
if(!callRequestController.iRequestedCall)
|
|
3191
3190
|
return;
|
|
3192
3191
|
|
|
3193
3192
|
chatEvents.fireEvent('callEvents', {
|
|
@@ -3195,12 +3194,9 @@ function ChatCall(params) {
|
|
|
3195
3194
|
result: messageContent
|
|
3196
3195
|
});
|
|
3197
3196
|
|
|
3198
|
-
if(!
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
//currentCallId = messageContent.callId;
|
|
3203
|
-
|
|
3197
|
+
// if(!requestedCallId) {
|
|
3198
|
+
requestedCallId = messageContent.callId;
|
|
3199
|
+
// }
|
|
3204
3200
|
break;
|
|
3205
3201
|
|
|
3206
3202
|
/**
|
|
@@ -3441,10 +3437,72 @@ function ChatCall(params) {
|
|
|
3441
3437
|
}
|
|
3442
3438
|
break;
|
|
3443
3439
|
|
|
3440
|
+
/**
|
|
3441
|
+
* Type 230 CALL_RECORDING_FAILED
|
|
3442
|
+
*/
|
|
3443
|
+
case chatMessageVOTypes.CALL_RECORDING_FAILED:
|
|
3444
|
+
if (chatMessaging.messagesCallbacks[uniqueId]) {
|
|
3445
|
+
chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount, uniqueId));
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3448
|
+
chatEvents.fireEvent('callEvents', {
|
|
3449
|
+
type: 'CALL_RECORDING_FAILED',
|
|
3450
|
+
result: messageContent
|
|
3451
|
+
});
|
|
3452
|
+
|
|
3453
|
+
break;
|
|
3454
|
+
|
|
3455
|
+
|
|
3456
|
+
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3460
|
+
function processChatStartCallEvent(type, messageContent, contentCount, threadId, uniqueId){
|
|
3461
|
+
if (chatMessaging.messagesCallbacks[uniqueId]) {
|
|
3462
|
+
chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
|
|
3463
|
+
}
|
|
3464
|
+
|
|
3465
|
+
messageContent.callId = threadId;
|
|
3466
|
+
chatEvents.fireEvent('callEvents', {
|
|
3467
|
+
type: 'CALL_STARTED',
|
|
3468
|
+
result: messageContent
|
|
3469
|
+
});
|
|
3470
|
+
|
|
3471
|
+
if (typeof messageContent === 'object'
|
|
3472
|
+
&& messageContent.hasOwnProperty('chatDataDto')
|
|
3473
|
+
&& !!messageContent.chatDataDto.kurentoAddress) {
|
|
3474
|
+
|
|
3475
|
+
callServerController.setServers(messageContent.chatDataDto.kurentoAddress.split(','));
|
|
3476
|
+
|
|
3477
|
+
startCallWebRTCFunctions({
|
|
3478
|
+
video: messageContent.clientDTO.video,
|
|
3479
|
+
mute: messageContent.clientDTO.mute,
|
|
3480
|
+
sendingTopic: messageContent.clientDTO.topicSend,
|
|
3481
|
+
receiveTopic: messageContent.clientDTO.topicReceive,
|
|
3482
|
+
screenShare: messageContent.chatDataDto.screenShare,
|
|
3483
|
+
brokerAddress: messageContent.chatDataDto.brokerAddressWeb,
|
|
3484
|
+
turnAddress: messageContent.chatDataDto.turnAddress,
|
|
3485
|
+
internalTurnAddress: messageContent.chatDataDto.internalTurnAddress,
|
|
3486
|
+
selfData: messageContent.clientDTO,
|
|
3487
|
+
clientsList: messageContent.otherClientDtoList,
|
|
3488
|
+
screenShareOwner: +messageContent.chatDataDto.screenShareUser,
|
|
3489
|
+
recordingOwner: +messageContent.chatDataDto.recordingUser
|
|
3490
|
+
}, function (callDivs) {
|
|
3491
|
+
chatEvents.fireEvent('callEvents', {
|
|
3492
|
+
type: 'CALL_DIVS',
|
|
3493
|
+
result: callDivs
|
|
3494
|
+
});
|
|
3495
|
+
});
|
|
3496
|
+
} else {
|
|
3497
|
+
chatEvents.fireEvent('callEvents', {
|
|
3498
|
+
type: 'CALL_ERROR',
|
|
3499
|
+
message: 'Chat Data DTO is not present!',
|
|
3500
|
+
environmentDetails: getSDKCallDetails()
|
|
3501
|
+
});
|
|
3444
3502
|
}
|
|
3445
3503
|
}
|
|
3446
3504
|
|
|
3447
|
-
this.startCall = function (params, callback) {
|
|
3505
|
+
this.startCall = async function (params, callback) {
|
|
3448
3506
|
let startCallData = {
|
|
3449
3507
|
chatMessageVOType: chatMessageVOTypes.CALL_REQUEST,
|
|
3450
3508
|
typeCode: generalTypeCode, //params.typeCode,
|
|
@@ -3510,10 +3568,15 @@ function ChatCall(params) {
|
|
|
3510
3568
|
return;
|
|
3511
3569
|
}
|
|
3512
3570
|
|
|
3571
|
+
// if(currentCallId) {
|
|
3572
|
+
// await callStop();
|
|
3573
|
+
// }
|
|
3574
|
+
|
|
3513
3575
|
callRequestController.cameraPaused = (typeof params.cameraPaused === 'boolean') ? params.cameraPaused : false;
|
|
3514
|
-
callRequestController.callRequestReceived = true;
|
|
3515
|
-
callRequestController.callEstablishedInMySide = true;
|
|
3516
|
-
callRequestController.imCallOwner = true;
|
|
3576
|
+
// callRequestController.callRequestReceived = true;
|
|
3577
|
+
// callRequestController.callEstablishedInMySide = true;
|
|
3578
|
+
// callRequestController.imCallOwner = true;
|
|
3579
|
+
callRequestController.iRequestedCall = true;
|
|
3517
3580
|
|
|
3518
3581
|
deviceManager.grantUserMediaDevicesPermissions({
|
|
3519
3582
|
video: params.type == 'video',
|
|
@@ -3553,7 +3616,7 @@ function ChatCall(params) {
|
|
|
3553
3616
|
});
|
|
3554
3617
|
};
|
|
3555
3618
|
|
|
3556
|
-
this.startGroupCall = function (params, callback) {
|
|
3619
|
+
this.startGroupCall = async function (params, callback) {
|
|
3557
3620
|
let startCallData = {
|
|
3558
3621
|
chatMessageVOType: chatMessageVOTypes.GROUP_CALL_REQUEST,
|
|
3559
3622
|
typeCode: generalTypeCode, //params.typeCode,
|
|
@@ -3619,10 +3682,15 @@ function ChatCall(params) {
|
|
|
3619
3682
|
return;
|
|
3620
3683
|
}
|
|
3621
3684
|
|
|
3685
|
+
// if(currentCallId) {
|
|
3686
|
+
// await callStop();
|
|
3687
|
+
// }
|
|
3688
|
+
|
|
3622
3689
|
callRequestController.cameraPaused = (typeof params.cameraPaused === 'boolean') ? params.cameraPaused : false;
|
|
3623
|
-
callRequestController.callRequestReceived = true;
|
|
3624
|
-
callRequestController.callEstablishedInMySide = true;
|
|
3625
|
-
callRequestController.imCallOwner = true;
|
|
3690
|
+
// callRequestController.callRequestReceived = true;
|
|
3691
|
+
// callRequestController.callEstablishedInMySide = true;
|
|
3692
|
+
// callRequestController.imCallOwner = true;
|
|
3693
|
+
callRequestController.iRequestedCall = true;
|
|
3626
3694
|
|
|
3627
3695
|
deviceManager.grantUserMediaDevicesPermissions({
|
|
3628
3696
|
video: params.type == 'video',
|
|
@@ -3641,7 +3709,7 @@ function ChatCall(params) {
|
|
|
3641
3709
|
if(callNoAnswerTimeout) {
|
|
3642
3710
|
callRequestController.callRequestTimeout = setTimeout( function(metaData) {
|
|
3643
3711
|
//Reject the call if participant didn't answer
|
|
3644
|
-
if(!callStopQueue.callStarted
|
|
3712
|
+
if(!callStopQueue.callStarted) {
|
|
3645
3713
|
chatEvents.fireEvent("callEvents", {
|
|
3646
3714
|
type: "CALL_NO_ANSWER_TIMEOUT",
|
|
3647
3715
|
message: "[CALL_SESSION_CREATED] Call request timed out, No answer",
|
|
@@ -3708,7 +3776,7 @@ function ChatCall(params) {
|
|
|
3708
3776
|
});
|
|
3709
3777
|
};
|
|
3710
3778
|
|
|
3711
|
-
this.acceptCall = function (params, callback) {
|
|
3779
|
+
this.acceptCall = async function (params, callback) {
|
|
3712
3780
|
let acceptCallData = {
|
|
3713
3781
|
chatMessageVOType: chatMessageVOTypes.ACCEPT_CALL,
|
|
3714
3782
|
typeCode: generalTypeCode, //params.typeCode,
|
|
@@ -3745,8 +3813,8 @@ function ChatCall(params) {
|
|
|
3745
3813
|
acceptCallData.content = JSON.stringify(content);
|
|
3746
3814
|
|
|
3747
3815
|
if(params.joinCall) {
|
|
3748
|
-
callRequestController.callRequestReceived = true;
|
|
3749
|
-
currentCallId = params.callId;
|
|
3816
|
+
// callRequestController.callRequestReceived = true;
|
|
3817
|
+
// currentCallId = params.callId;
|
|
3750
3818
|
}
|
|
3751
3819
|
} else {
|
|
3752
3820
|
chatEvents.fireEvent('error', {
|
|
@@ -3756,12 +3824,64 @@ function ChatCall(params) {
|
|
|
3756
3824
|
return;
|
|
3757
3825
|
}
|
|
3758
3826
|
|
|
3759
|
-
callRequestController.
|
|
3760
|
-
|
|
3827
|
+
// if(callRequestController.iAcceptedCall || callRequestController.iRequestedCall) {
|
|
3828
|
+
// await callStop();
|
|
3829
|
+
// }
|
|
3830
|
+
|
|
3831
|
+
// if(currentCallId) {
|
|
3832
|
+
// endCall({callId: currentCallId});
|
|
3833
|
+
// }
|
|
3761
3834
|
|
|
3762
|
-
|
|
3835
|
+
acceptedCallId = parseInt(params.callId);
|
|
3836
|
+
callRequestController.iAcceptedCall = true;
|
|
3837
|
+
// console.log("acceptCall: ", {acceptedCallId}, callRequestController.iAcceptedCall);
|
|
3838
|
+
// callRequestController.imCallOwner = false;
|
|
3839
|
+
// callRequestController.callEstablishedInMySide = true;
|
|
3763
3840
|
|
|
3764
|
-
|
|
3841
|
+
// let isMovingToNewCall = false;
|
|
3842
|
+
|
|
3843
|
+
deviceManager.grantUserMediaDevicesPermissions({
|
|
3844
|
+
video: params.video,
|
|
3845
|
+
audio: !params.mute,
|
|
3846
|
+
closeStream: true
|
|
3847
|
+
}, function (result) {
|
|
3848
|
+
if (result.hasError) {
|
|
3849
|
+
callback && callback({
|
|
3850
|
+
hasError: true,
|
|
3851
|
+
errorCode: result.errorCode,
|
|
3852
|
+
errorMessage: result.errorMessage,
|
|
3853
|
+
});
|
|
3854
|
+
return;
|
|
3855
|
+
}
|
|
3856
|
+
|
|
3857
|
+
chatMessaging.sendMessage(acceptCallData, {
|
|
3858
|
+
onResult: function (result) {
|
|
3859
|
+
// if(!result.hasError && isMovingToNewCall) {
|
|
3860
|
+
// chatEvents.fireEvent("callEvents", {
|
|
3861
|
+
// type: 'MOVING_TO_NEW_CALL',
|
|
3862
|
+
// status: 'DONE',
|
|
3863
|
+
// result: {
|
|
3864
|
+
// oldCall: currentCallId,
|
|
3865
|
+
// newCall: params.callId
|
|
3866
|
+
// }
|
|
3867
|
+
// });
|
|
3868
|
+
// } else {
|
|
3869
|
+
// chatEvents.fireEvent("callEvents", {
|
|
3870
|
+
// type: 'MOVING_TO_NEW_CALL',
|
|
3871
|
+
// status: 'FAILED',
|
|
3872
|
+
// result: {
|
|
3873
|
+
// oldCall: currentCallId,
|
|
3874
|
+
// newCall: params.callId
|
|
3875
|
+
// }
|
|
3876
|
+
// });
|
|
3877
|
+
// }
|
|
3878
|
+
|
|
3879
|
+
callback && callback(result);
|
|
3880
|
+
}
|
|
3881
|
+
});
|
|
3882
|
+
});
|
|
3883
|
+
|
|
3884
|
+
/* new Promise((resolve, reject) => {
|
|
3765
3885
|
if(callStopQueue.callStarted) {
|
|
3766
3886
|
isMovingToNewCall = true;
|
|
3767
3887
|
// callStop(false);
|
|
@@ -3776,9 +3896,9 @@ function ChatCall(params) {
|
|
|
3776
3896
|
endCall({callId: currentCallId});
|
|
3777
3897
|
setTimeout(()=>{
|
|
3778
3898
|
resolve(true);
|
|
3779
|
-
callRequestController.imCallOwner = false;
|
|
3780
|
-
callRequestController.callEstablishedInMySide = true;
|
|
3781
|
-
callRequestController.callRequestReceived = true;
|
|
3899
|
+
// callRequestController.imCallOwner = false;
|
|
3900
|
+
// callRequestController.callEstablishedInMySide = true;
|
|
3901
|
+
// callRequestController.callRequestReceived = true;
|
|
3782
3902
|
currentCallId = params.callId;
|
|
3783
3903
|
chatEvents.fireEvent('callEvents', {
|
|
3784
3904
|
type: 'CALL_SESSION_CREATED',
|
|
@@ -3840,7 +3960,7 @@ function ChatCall(params) {
|
|
|
3840
3960
|
}
|
|
3841
3961
|
});
|
|
3842
3962
|
});
|
|
3843
|
-
})
|
|
3963
|
+
})*/
|
|
3844
3964
|
};
|
|
3845
3965
|
|
|
3846
3966
|
this.rejectCall = this.cancelCall = function (params, callback) {
|