teleportxr 1.0.40 → 1.0.42
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 +23 -1
- package/connections/webrtcconnection.js +24 -16
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -125,6 +125,10 @@ class Client {
|
|
|
125
125
|
{
|
|
126
126
|
this.setupCommand=new command.SetupCommand();
|
|
127
127
|
this.clientDynamicLighting=new core.ClientDynamicLighting();
|
|
128
|
+
// Session is (re)starting; the client has zero state, so retract any
|
|
129
|
+
// outstanding ack tracking from a previous session and force a resend.
|
|
130
|
+
this.currentOriginState = new OriginState();
|
|
131
|
+
this.currentLightingState = new LightingState();
|
|
128
132
|
this.setupCommand.float32_draw_distance=10.0;
|
|
129
133
|
if(this.scene)
|
|
130
134
|
{
|
|
@@ -348,7 +352,25 @@ class Client {
|
|
|
348
352
|
var setl =new command.SetLightingCommand();
|
|
349
353
|
setl.uint64_ackId =this.next_ack_id++;
|
|
350
354
|
setl.ClientDynamicLighting_clientDynamicLighting = this.clientDynamicLighting;
|
|
351
|
-
|
|
355
|
+
|
|
356
|
+
// Log in declaration order matching ClientDynamicLighting / SetLightingCommand structs.
|
|
357
|
+
const cdl = setl.ClientDynamicLighting_clientDynamicLighting;
|
|
358
|
+
console.log("\n===== NODE SERVER SENDING SETLIGHTINGCOMMAND =====");
|
|
359
|
+
console.log(JSON.stringify({
|
|
360
|
+
ack_id: setl.uint64_ackId.toString(),
|
|
361
|
+
specularPos: cdl.int2_specularPos,
|
|
362
|
+
specularCubemapSize: cdl.int32_specularCubemapSize,
|
|
363
|
+
specularMips: cdl.int32_specularMips,
|
|
364
|
+
diffusePos: cdl.int2_diffusePos,
|
|
365
|
+
diffuseCubemapSize: cdl.int32_diffuseCubemapSize,
|
|
366
|
+
lightPos: cdl.int2_lightPos,
|
|
367
|
+
lightCubemapSize: cdl.int32_lightCubemapSize,
|
|
368
|
+
specular_cubemap_texture_uid: cdl.uid_specular_cubemap_texture_uid.toString(),
|
|
369
|
+
diffuse_cubemap_texture_uid: cdl.uid_diffuse_cubemap_texture_uid.toString(),
|
|
370
|
+
lightingMode: cdl.LightingMode_lightingMode,
|
|
371
|
+
}, null, 2));
|
|
372
|
+
console.log("===== END SETLIGHTINGCOMMAND =====\n");
|
|
373
|
+
|
|
352
374
|
// This is now the valid origin.
|
|
353
375
|
this.currentLightingState.ackId=setl.uint64_ackId;
|
|
354
376
|
this.currentLightingState.acknowledged=false;
|
|
@@ -103,6 +103,21 @@ class WebRtcConnection extends EventEmitter
|
|
|
103
103
|
}
|
|
104
104
|
reconnect()
|
|
105
105
|
{
|
|
106
|
+
// Close and clean up the previous PeerConnection before creating a new one.
|
|
107
|
+
// Failing to do so leaves the old ICE agent (and its UDP socket) alive, which
|
|
108
|
+
// causes it to keep sending/receiving STUN messages with stale credentials and
|
|
109
|
+
// confuses the peer's new ICE agent (ufrag mismatch).
|
|
110
|
+
if (this.peerConnection)
|
|
111
|
+
{
|
|
112
|
+
this.peerConnection.removeEventListener('iceconnectionstatechange', this._onIceConnectionStateChange);
|
|
113
|
+
this.peerConnection.removeEventListener('icegatheringstatechange', this._onIceGatheringStateChange);
|
|
114
|
+
this.peerConnection.removeEventListener("icecandidateerror", this._onIceCandidateError);
|
|
115
|
+
this.peerConnection.removeEventListener("connectionstatechange", this._onConnectionStateChange);
|
|
116
|
+
if (this.onIceCandidate)
|
|
117
|
+
this.peerConnection.removeEventListener('icecandidate', this.onIceCandidate);
|
|
118
|
+
try { this.peerConnection.close(); } catch (e) {}
|
|
119
|
+
this.peerConnection = null;
|
|
120
|
+
}
|
|
106
121
|
this.peerConnection =new DefaultRTCPeerConnection({ sdpSemantics: 'unified-plan', iceServers: this.iceServers, iceTransportPolicy: this.iceTransportPolicy});
|
|
107
122
|
this.beforeOffer();
|
|
108
123
|
this.connectionTimer = this.options.setTimeout(() =>
|
|
@@ -267,8 +282,9 @@ class WebRtcConnection extends EventEmitter
|
|
|
267
282
|
} else if (this.peerConnection.iceConnectionState === 'disconnected'
|
|
268
283
|
|| this.peerConnection.iceConnectionState === 'failed')
|
|
269
284
|
{
|
|
270
|
-
|
|
271
|
-
|
|
285
|
+
// Do not call restartIce() here: reconnect() below creates a brand-new
|
|
286
|
+
// PeerConnection, so any ICE restart on the old PC is immediately
|
|
287
|
+
// abandoned and produces a third set of dangling ICE credentials.
|
|
272
288
|
if (!this.connectionTimer && !this.reconnectionTimer)
|
|
273
289
|
{
|
|
274
290
|
const self = this;
|
|
@@ -312,21 +328,13 @@ class WebRtcConnection extends EventEmitter
|
|
|
312
328
|
this.reconnectionTimer = null;
|
|
313
329
|
}
|
|
314
330
|
|
|
315
|
-
//
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
331
|
+
// Always close the PeerConnection regardless of connectionState.
|
|
332
|
+
// Previously it was only closed when state was "connected" or "failed",
|
|
333
|
+
// which left the ICE agent alive (and its socket bound) when state was
|
|
334
|
+
// "disconnected", causing stale STUN traffic toward the peer on reconnect.
|
|
335
|
+
if (this.peerConnection)
|
|
319
336
|
{
|
|
320
|
-
|
|
321
|
-
/* this.peerConnection.cl.forEach(mediaStream => { {
|
|
322
|
-
mediaStream.videoTracks.forEach( it => {it.setEnabled(false); });
|
|
323
|
-
mediaStream.audioTracks.forEach( it => {it.setEnabled(false); });
|
|
324
|
-
|
|
325
|
-
};
|
|
326
|
-
});;6'7*/
|
|
327
|
-
|
|
328
|
-
// Close the connection
|
|
329
|
-
this.peerConnection.close();
|
|
337
|
+
try { this.peerConnection.close(); } catch (e) {}
|
|
330
338
|
}
|
|
331
339
|
|
|
332
340
|
// Nullify the reference
|
package/package.json
CHANGED