@subiz/wsclient 4.0.11 → 4.0.12
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/package.json +1 -1
- package/webrtc.js +18 -16
package/package.json
CHANGED
package/webrtc.js
CHANGED
|
@@ -267,7 +267,7 @@ function WebRTCConn(options) {
|
|
|
267
267
|
}
|
|
268
268
|
})
|
|
269
269
|
|
|
270
|
-
this.makeCall = (number, fromnumber,
|
|
270
|
+
this.makeCall = (number, fromnumber, streamPm, callid) => {
|
|
271
271
|
if (!callid) callid = 'webcall-' + randomString(30)
|
|
272
272
|
let now = env.Date.now()
|
|
273
273
|
let call = {
|
|
@@ -283,26 +283,28 @@ function WebRTCConn(options) {
|
|
|
283
283
|
dialingRequest[callid] = call
|
|
284
284
|
publish({type: 'call_ringing', data: {call_info: {call_id: callid}}}) // fake dialing
|
|
285
285
|
return new env.Promise((rs) => {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
endRequest[callid] = env.Date.now()
|
|
290
|
-
publish({type: 'call_ended', data: {call_info: {call_id: callid}}})
|
|
291
|
-
return rs({error: err})
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
let url = `${apiUrl}call?x-access-token=${access_token}&connection_id=${connId}&call_id=${callid}&number=${number}&from_number=${fromnumber}`
|
|
295
|
-
callAPI('post', url, undefined, (body, code) => {
|
|
296
|
-
if (code != 200) {
|
|
286
|
+
streamPm.then(stream => {
|
|
287
|
+
this.joinCall(callid, stream, (err) => {
|
|
288
|
+
if (err) {
|
|
297
289
|
delete dialingRequest[callid]
|
|
298
290
|
endRequest[callid] = env.Date.now()
|
|
299
291
|
publish({type: 'call_ended', data: {call_info: {call_id: callid}}})
|
|
300
292
|
return rs({error: err})
|
|
301
293
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
294
|
+
|
|
295
|
+
let url = `${apiUrl}call?x-access-token=${access_token}&connection_id=${connId}&call_id=${callid}&number=${number}&from_number=${fromnumber}`
|
|
296
|
+
callAPI('post', url, undefined, (body, code) => {
|
|
297
|
+
if (code != 200) {
|
|
298
|
+
delete dialingRequest[callid]
|
|
299
|
+
endRequest[callid] = env.Date.now()
|
|
300
|
+
publish({type: 'call_ended', data: {call_info: {call_id: callid}}})
|
|
301
|
+
return rs({error: err})
|
|
302
|
+
}
|
|
303
|
+
body = parseJSON(body)
|
|
304
|
+
if (body) activeCalls[callid] = body
|
|
305
|
+
delete dialingRequest[callid]
|
|
306
|
+
rs({body})
|
|
307
|
+
})
|
|
306
308
|
})
|
|
307
309
|
})
|
|
308
310
|
})
|