teleportxr 1.0.26 → 1.0.28

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/client/client.js CHANGED
@@ -221,7 +221,7 @@ class Client {
221
221
  }
222
222
  ProcessNodePoses(headPose,numPoses,nodePoses)
223
223
  {
224
- console.log("Client: ProcessNodePoses ", numPoses, " poses.");
224
+ //console.log("Client: ProcessNodePoses ", numPoses, " poses.");
225
225
  }
226
226
  UpdateStreaming()
227
227
  {
@@ -21,9 +21,22 @@ class WebRtcConnection extends EventEmitter
21
21
  const defaultIceServers = [
22
22
  { urls: "stun:stun.l.google.com:19302" }
23
23
  ];
24
- this.iceServers = (options && Array.isArray(options.iceServers) && options.iceServers.length)
24
+ const requestedIceServers = (options && Array.isArray(options.iceServers) && options.iceServers.length)
25
25
  ? options.iceServers
26
26
  : defaultIceServers;
27
+ // @roamhq/wrtc rejects the entire iceServers array if any TURN entry lacks
28
+ // credentials, and TURN can't function without auth, so drop those with a warning.
29
+ this.iceServers = requestedIceServers.filter((s) =>
30
+ {
31
+ const urls = Array.isArray(s.urls) ? s.urls : [s.urls];
32
+ const isTurn = urls.some((u) => u && (u.startsWith('turn:') || u.startsWith('turns:')));
33
+ if (isTurn && (!s.username || !s.credential))
34
+ {
35
+ console.warn("WebRtcConnection: skipping TURN entry without credentials: "+JSON.stringify(s));
36
+ return false;
37
+ }
38
+ return true;
39
+ });
27
40
  this.iceTransportPolicy = (options && (options.iceTransportPolicy === 'all' || options.iceTransportPolicy === 'relay'))
28
41
  ? options.iceTransportPolicy
29
42
  : 'all';
@@ -113,9 +126,8 @@ class WebRtcConnection extends EventEmitter
113
126
  {
114
127
  if (!candidate)
115
128
  {
116
- this.options.clearTimeout(this.timeout);
117
- //this.peerConnection.removeEventListener('icecandidate', this.onIceCandidate);
118
- this.deferred.resolve();
129
+ if (this.iceGatheringSettle)
130
+ this.iceGatheringSettle();
119
131
  return;
120
132
  }
121
133
  // send the candidate
@@ -130,24 +142,42 @@ class WebRtcConnection extends EventEmitter
130
142
  {
131
143
  return;
132
144
  }
133
-
145
+
134
146
  const { timeToHostCandidates } = options;
135
-
147
+
136
148
  this.deferred = {};
137
149
  this.deferred.promise = new Promise((resolve, reject) =>
138
150
  {
139
151
  this.deferred.resolve = resolve;
140
152
  this.deferred.reject = reject;
141
153
  });
142
-
143
- this.timeout = options.setTimeout(() =>
154
+
155
+ const onGatheringStateChange = () =>
144
156
  {
145
- peerConnection.removeEventListener('icecandidate', this.onIceCandidate);
146
- this.deferred.reject(new Error('Timed out waiting for host candidates'));
147
- }, timeToHostCandidates);
157
+ if (peerConnection.iceGatheringState === 'complete')
158
+ this.iceGatheringSettle();
159
+ };
148
160
 
161
+ let settled = false;
162
+ this.iceGatheringSettle = () =>
163
+ {
164
+ if (settled) return;
165
+ settled = true;
166
+ this.options.clearTimeout(this.timeout);
167
+ peerConnection.removeEventListener('icegatheringstatechange', onGatheringStateChange);
168
+ this.deferred.resolve();
169
+ };
170
+
171
+ // Trickle ICE is in use; the offer and any already-gathered candidates
172
+ // have been sent. If gathering is slow (e.g. a TURN allocation is
173
+ // timing out), resolve rather than reject so doOffer does not tear
174
+ // down the connection. Remaining candidates will still be sent by
175
+ // the persistent 'icecandidate' listener.
176
+ this.timeout = options.setTimeout(() => this.iceGatheringSettle(), timeToHostCandidates);
177
+
178
+ peerConnection.addEventListener('icegatheringstatechange', onGatheringStateChange);
149
179
  peerConnection.addEventListener('icecandidate', this.onIceCandidate);
150
-
180
+
151
181
  await this.deferred.promise;
152
182
  }
153
183
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@lightningjs/msdf-generator": "^1.1.1",
4
- "@roamhq/wrtc": "^0.8.0",
4
+ "@roamhq/wrtc": "^0.10.0",
5
5
  "bitset": "^5.2.3",
6
6
  "get-current-line": "^7.4.0",
7
7
  "microtime": "^3.1.1",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "name": "teleportxr",
17
17
  "description": "Teleport Spatial Server on node.js",
18
- "version": "1.0.26",
18
+ "version": "1.0.28",
19
19
  "repository": {
20
20
  "type": "git",
21
21
  "url": "git+https://github.com/simul/teleport-nodejs.git"