@subiz/wsclient 4.0.5 → 4.0.6

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 +1 -1
  2. package/webrtc.js +6 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/wsclient",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "main": "realtime.js",
5
5
  "scripts": {
6
6
  "test": "node realtime.test.js"
package/webrtc.js CHANGED
@@ -4,9 +4,9 @@ const servers = {
4
4
  iceServers: [{urls: ['stun:stun.l.google.com:19302?transport=tcp']}],
5
5
  }
6
6
 
7
- // let connId = 'webrtc' + sb.randomString(20)
7
+ // let connId = 'webrtc' + randomString(20)
8
8
  // env = {RTCPeerConnection, RTCIceCandidate, RTCSessionDescription, setTimeout, setInterval, jsonify, parseJSON}
9
- // setting env._is_webrtc_local to true for local testing
9
+ // set env._is_webrtc_local to true for local testing
10
10
  function WebRTCConn(options) {
11
11
  let {apiUrl, access_token, accid, agid, connId, realtime, callAPI, env, onTrack, onEvent} = options
12
12
  if (!apiUrl) {
@@ -318,10 +318,13 @@ function WebRTCConn(options) {
318
318
  }
319
319
 
320
320
  this.answerCall = (callid, stream) => {
321
+ console.log('1')
321
322
  let call = activeCalls[callid]
322
- if (!call || call.status == 'ended') return Promise.resolve({error: 'call_ended'})
323
+ if (call && call.status == 'ended') return Promise.resolve({error: 'call_ended'})
323
324
  let now = env.Date.now()
325
+ console.log('2', answerRequest[callid])
324
326
  if (answerRequest[callid]) return Promise.resolve({body: call})
327
+ console.log('3')
325
328
  answerRequest[callid] = now
326
329
  publish({type: 'call_ringing', data: {call_info: {call_id: callid}}}) // fake dialing
327
330
  return new env.Promise((rs) => {