@subiz/wsclient 4.0.3 → 4.0.4

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 +9 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/wsclient",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "main": "realtime.js",
5
5
  "scripts": {
6
6
  "test": "node realtime.test.js"
package/webrtc.js CHANGED
@@ -31,6 +31,7 @@ function WebRTCConn(options) {
31
31
  let activeCalls = {}
32
32
 
33
33
  let dialingRequest = {}
34
+ let answerRequest = {}
34
35
  let endRequest = {}
35
36
 
36
37
  let subscribe = realtime.subscribe([
@@ -70,10 +71,8 @@ function WebRTCConn(options) {
70
71
  if (!needConnect) return
71
72
  peer = new env.RTCPeerConnection(servers)
72
73
  let mypeer = peer
73
- window.peer = peer
74
74
 
75
75
  readyToSendCandidate = new env.Promise((rs) => (readyToSendCandidateResolve = rs))
76
-
77
76
  peer.ontrack = (event) => {
78
77
  if (peer != mypeer) return // outdated
79
78
  onTrack && onTrack(event)
@@ -161,19 +160,26 @@ function WebRTCConn(options) {
161
160
  hangup_code: 'cancel',
162
161
  })
163
162
  })
163
+
164
+ Object.keys(answerRequest).map((callid) => {
165
+ let call = calls[callid]
166
+ if (!call) return
167
+ call.answer_requested = answerRequest[callid]
168
+ })
164
169
  return calls
165
170
  }
166
171
 
167
172
  let call = activeCalls[callid]
168
173
  if (!call && dialingRequest[callid]) call = dialingRequest[callid]
169
174
  if (endRequest[callid] && call && call.status != 'ended') {
170
- return Object.assign({}, call, {
175
+ call = Object.assign({}, call, {
171
176
  call_id: callid,
172
177
  ended: endRequest[callid],
173
178
  status: 'ended',
174
179
  hangup_code: 'cancel',
175
180
  })
176
181
  }
182
+ if (answerRequest[callid]) call = Object.assign({}, call, {answer_requested: answerRequest[callid]})
177
183
  return call
178
184
  }
179
185