@subiz/wsclient 4.0.6 → 4.0.7

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/webrtc.js +4 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/wsclient",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "main": "realtime.js",
5
5
  "scripts": {
6
6
  "test": "node realtime.test.js"
@@ -14,7 +14,7 @@
14
14
  "homepage": "https://github.com/subiz/wsclient#readme",
15
15
  "description": "",
16
16
  "devDependencies": {
17
- "tape": "^5.6.1"
17
+ "tape": "^5.6.3"
18
18
  },
19
19
  "dependencies": {
20
20
  "@subiz/flow": "^1.0.9",
package/webrtc.js CHANGED
@@ -243,8 +243,8 @@ function WebRTCConn(options) {
243
243
  }
244
244
  })
245
245
 
246
- this.makeCall = (number, fromnumber, stream) => {
247
- let callid = 'webcall-' + randomString(30)
246
+ this.makeCall = (number, fromnumber, stream, callid) => {
247
+ if (!callid) callid = 'webcall-' + randomString(30)
248
248
  let now = env.Date.now()
249
249
  let call = {
250
250
  account_id: accid,
@@ -294,8 +294,9 @@ function WebRTCConn(options) {
294
294
  }
295
295
  call.status = 'ended'
296
296
  call.ended = env.Date.now()
297
- callAPI('post', `${apiUrl}hangup?x-access-token=${access_token}&connection_id=${connId}&call_id=${callid}`)
298
297
  publish({type: 'call_ended', data: {call_info: {call_id: callid}}})
298
+
299
+ callAPI('post', `${apiUrl}hangup?x-access-token=${access_token}&connection_id=${connId}&call_id=${callid}`)
299
300
  }
300
301
 
301
302
  this.listenCall = (callid, cb) => {
@@ -318,13 +319,10 @@ function WebRTCConn(options) {
318
319
  }
319
320
 
320
321
  this.answerCall = (callid, stream) => {
321
- console.log('1')
322
322
  let call = activeCalls[callid]
323
323
  if (call && call.status == 'ended') return Promise.resolve({error: 'call_ended'})
324
324
  let now = env.Date.now()
325
- console.log('2', answerRequest[callid])
326
325
  if (answerRequest[callid]) return Promise.resolve({body: call})
327
- console.log('3')
328
326
  answerRequest[callid] = now
329
327
  publish({type: 'call_ringing', data: {call_info: {call_id: callid}}}) // fake dialing
330
328
  return new env.Promise((rs) => {