teleportxr 1.0.26 → 1.0.27

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
  {
@@ -113,9 +113,8 @@ class WebRtcConnection extends EventEmitter
113
113
  {
114
114
  if (!candidate)
115
115
  {
116
- this.options.clearTimeout(this.timeout);
117
- //this.peerConnection.removeEventListener('icecandidate', this.onIceCandidate);
118
- this.deferred.resolve();
116
+ if (this.iceGatheringSettle)
117
+ this.iceGatheringSettle();
119
118
  return;
120
119
  }
121
120
  // send the candidate
@@ -130,24 +129,42 @@ class WebRtcConnection extends EventEmitter
130
129
  {
131
130
  return;
132
131
  }
133
-
132
+
134
133
  const { timeToHostCandidates } = options;
135
-
134
+
136
135
  this.deferred = {};
137
136
  this.deferred.promise = new Promise((resolve, reject) =>
138
137
  {
139
138
  this.deferred.resolve = resolve;
140
139
  this.deferred.reject = reject;
141
140
  });
142
-
143
- this.timeout = options.setTimeout(() =>
141
+
142
+ const onGatheringStateChange = () =>
144
143
  {
145
- peerConnection.removeEventListener('icecandidate', this.onIceCandidate);
146
- this.deferred.reject(new Error('Timed out waiting for host candidates'));
147
- }, timeToHostCandidates);
144
+ if (peerConnection.iceGatheringState === 'complete')
145
+ this.iceGatheringSettle();
146
+ };
148
147
 
148
+ let settled = false;
149
+ this.iceGatheringSettle = () =>
150
+ {
151
+ if (settled) return;
152
+ settled = true;
153
+ this.options.clearTimeout(this.timeout);
154
+ peerConnection.removeEventListener('icegatheringstatechange', onGatheringStateChange);
155
+ this.deferred.resolve();
156
+ };
157
+
158
+ // Trickle ICE is in use; the offer and any already-gathered candidates
159
+ // have been sent. If gathering is slow (e.g. a TURN allocation is
160
+ // timing out), resolve rather than reject so doOffer does not tear
161
+ // down the connection. Remaining candidates will still be sent by
162
+ // the persistent 'icecandidate' listener.
163
+ this.timeout = options.setTimeout(() => this.iceGatheringSettle(), timeToHostCandidates);
164
+
165
+ peerConnection.addEventListener('icegatheringstatechange', onGatheringStateChange);
149
166
  peerConnection.addEventListener('icecandidate', this.onIceCandidate);
150
-
167
+
151
168
  await this.deferred.promise;
152
169
  }
153
170
 
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.27",
19
19
  "repository": {
20
20
  "type": "git",
21
21
  "url": "git+https://github.com/simul/teleport-nodejs.git"