@subiz/wsclient 4.0.14 → 4.0.16
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 +2 -2
- package/webrtc.js +13 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/wsclient",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.16",
|
|
4
4
|
"main": "realtime.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node realtime.test.js"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"tape": "^5.6.3"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@subiz/flow": "^1.0
|
|
20
|
+
"@subiz/flow": "^1.1.0",
|
|
21
21
|
"request": "^2.88.2"
|
|
22
22
|
}
|
|
23
23
|
}
|
package/webrtc.js
CHANGED
|
@@ -270,16 +270,17 @@ function WebRTCConn(options) {
|
|
|
270
270
|
.then(() => {
|
|
271
271
|
readyToSendCandidateResolve[connId]()
|
|
272
272
|
let stream = streams[connId]
|
|
273
|
-
stream &&
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
273
|
+
stream &&
|
|
274
|
+
stream.getTracks().forEach((track) => {
|
|
275
|
+
let replaced = false
|
|
276
|
+
peer.getSenders().forEach((sender) => {
|
|
277
|
+
if (!sender.track) return
|
|
278
|
+
if (sender.track.kind != track.kind) return
|
|
279
|
+
sender.replaceTrack(track)
|
|
280
|
+
replaced = true
|
|
281
|
+
})
|
|
282
|
+
if (!replaced) peer.addTrack(track, stream)
|
|
280
283
|
})
|
|
281
|
-
if (!replaced) peer.addTrack(track, stream)
|
|
282
|
-
})
|
|
283
284
|
return peer.createAnswer()
|
|
284
285
|
})
|
|
285
286
|
.then((answer) =>
|
|
@@ -322,7 +323,7 @@ function WebRTCConn(options) {
|
|
|
322
323
|
}
|
|
323
324
|
})
|
|
324
325
|
|
|
325
|
-
this.makeCall = (number, fromnumber, streamPm, callid) => {
|
|
326
|
+
this.makeCall = (number, fromnumber, streamPm, callid, campaignid, outboundcallentryid) => {
|
|
326
327
|
if (!callid) callid = 'webcall-' + randomString(30)
|
|
327
328
|
let now = env.Date.now()
|
|
328
329
|
let call = {
|
|
@@ -333,6 +334,7 @@ function WebRTCConn(options) {
|
|
|
333
334
|
started: now,
|
|
334
335
|
status: 'dialing',
|
|
335
336
|
to_number: number,
|
|
337
|
+
from_number: fromnumber,
|
|
336
338
|
}
|
|
337
339
|
dialingRequest[callid] = call
|
|
338
340
|
publish({type: 'call_ringing', data: {call_info: {call_id: callid}}}) // fake dialing
|
|
@@ -347,7 +349,7 @@ function WebRTCConn(options) {
|
|
|
347
349
|
return rs({error: err})
|
|
348
350
|
}
|
|
349
351
|
|
|
350
|
-
let url = `${apiUrl}call?x-access-token=${access_token}&connection_id=${connId}&call_id=${callid}&number=${number}&from_number=${fromnumber}`
|
|
352
|
+
let url = `${apiUrl}call?x-access-token=${access_token}&connection_id=${connId}&call_id=${callid}&number=${number}&from_number=${fromnumber}&campaign_id=${campaignid}&outbound_call_entry_id=${outboundcallentryid}`
|
|
351
353
|
callAPI('post', url, undefined, (body, code) => {
|
|
352
354
|
if (code != 200) {
|
|
353
355
|
delete dialingRequest[callid]
|