teleportxr 1.0.69 → 1.0.71

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
@@ -289,6 +289,11 @@ class Client {
289
289
  this.webRtcConnectionManager.destroyConnection(this.clientID);
290
290
  this.webRtcConnection=null;
291
291
  this.webRtcConnectionManager=null;
292
+ // Clear connected state so UpdateStreaming stops iterating and the
293
+ // timeout reaper can handle removal if the client is still in the map.
294
+ this.webRtcConnected=false;
295
+ this.webRtcConnectedAtMs=0;
296
+ this.webRtcConnectionInitiatedAtMs=0;
292
297
  }
293
298
  // Generic message acknowledgement. Certain kinds of message are expected to be ack'ed.
294
299
  ReceiveAcknowledgement(data)
@@ -529,7 +534,7 @@ class Client {
529
534
  const view2 = new DataView(buffer, 0, nodeSize);
530
535
  if(!this.webRtcConnection)
531
536
  {
532
- console.error("this.webRtcConnection is null");
537
+ console.error("Client "+this.clientID+", SendNode "+uid+": this.webRtcConnection is null");
533
538
  return;
534
539
  }
535
540
  if(!this.webRtcConnection.isGeometryOpen())
@@ -539,7 +544,7 @@ class Client {
539
544
  return;
540
545
  }
541
546
  const sendSuccess = this.webRtcConnection.sendGeometry(view2);
542
- console.log("Sending node "+uid+" "+node.name+" to Client "+this.clientID+", size: "+nodeSize+" bytes — "+
547
+ console.log("[T+"+this.elapsedMsSinceStart()+"ms, conn+"+this.elapsedMsSinceConnected()+"ms] Sending node "+uid+" "+node.name+" to Client "+this.clientID+", size: "+nodeSize+" bytes — "+
543
548
  (sendSuccess ? "OK" : "FAILED"));
544
549
  if(sendSuccess)
545
550
  this.geometryService.EncodedResource(uid);
@@ -568,7 +573,7 @@ class Client {
568
573
  return;
569
574
  }
570
575
  const sendSuccess = this.webRtcConnection.sendGeometry(view2);
571
- console.log("Sending resource "+uid+" "+resource.url+" to Client "+this.clientID+", size: "+resourceSize+" bytes — "+
576
+ console.log("[T+"+this.elapsedMsSinceStart()+"ms, conn+"+this.elapsedMsSinceConnected()+"ms] Sending resource "+uid+" "+resource.url+" to Client "+this.clientID+", size: "+resourceSize+" bytes — "+
572
577
  (sendSuccess ? "OK" : "FAILED"));
573
578
  if(sendSuccess)
574
579
  this.geometryService.EncodedResource(uid);
@@ -116,11 +116,11 @@ class ClientManager
116
116
  return c;
117
117
  }
118
118
  disconnectClient(clientID) {
119
- // then we tell the client manager to start this client.
120
119
  var c=this.GetClient(clientID);
121
120
  if(!c)
122
121
  return;
123
122
  c.StopStreaming();
123
+ this.RemoveClient(clientID);
124
124
  }
125
125
  writeState() {
126
126
  var content="<table><tr><th>Client Id</th><th>IP Address</th><th>Signalling State</th></tr>";
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "name": "teleportxr",
18
18
  "description": "Teleport Spatial Server on node.js",
19
- "version": "1.0.69",
19
+ "version": "1.0.71",
20
20
  "repository": {
21
21
  "type": "git",
22
22
  "url": "git+https://github.com/simul/teleport-nodejs.git"
@@ -58,6 +58,43 @@ test('hasWebRtcConnectionTimedOut returns true when over timeout', async () => {
58
58
  assert.strictEqual(c.hasWebRtcConnectionTimedOut(), true);
59
59
  });
60
60
 
61
+ test('Client.StopStreaming clears webRtcConnected flags', () => {
62
+ // Simulate a connected client whose underlying connection is being torn down.
63
+ const c = makeStubClient({ clientID: 99 });
64
+ c.webRtcConnected = true;
65
+ c.webRtcConnectedAtMs = Date.now() - 5000;
66
+ c.webRtcConnectionInitiatedAtMs = Date.now() - 6000;
67
+ c.webRtcConnection = {};
68
+ c.webRtcConnectionManager = { destroyConnection: () => {} };
69
+
70
+ // Call the real StopStreaming from the prototype.
71
+ Client.prototype.StopStreaming.call(c);
72
+
73
+ assert.strictEqual(c.webRtcConnected, false, 'webRtcConnected must be false after StopStreaming');
74
+ assert.strictEqual(c.webRtcConnectedAtMs, 0, 'webRtcConnectedAtMs must be reset');
75
+ assert.strictEqual(c.webRtcConnectionInitiatedAtMs, 0, 'webRtcConnectionInitiatedAtMs must be reset');
76
+ assert.strictEqual(c.webRtcConnection, null, 'webRtcConnection must be null');
77
+ });
78
+
79
+ test('ClientManager.disconnectClient removes client from map', () => {
80
+ const cm = new ClientManager();
81
+ const stopStreamingCalled = [];
82
+
83
+ const c = makeStubClient({ clientID: 42 });
84
+ // Replace StopStreaming so we can track it and exercise the real path.
85
+ c.webRtcConnectionManager = null;
86
+ // Bind real StopStreaming but track the call.
87
+ const realStop = Client.prototype.StopStreaming.bind(c);
88
+ c.StopStreaming = () => { stopStreamingCalled.push(42); realStop(); };
89
+
90
+ cm.clients.set(42, c);
91
+
92
+ cm.disconnectClient(42);
93
+
94
+ assert.deepStrictEqual(stopStreamingCalled, [42], 'StopStreaming must be called');
95
+ assert.strictEqual(cm.clients.has(42), false, 'client must be removed from the map');
96
+ });
97
+
61
98
  test('ClientManager.UpdateStreaming removes timed-out clients', async () => {
62
99
  const cm = new ClientManager();
63
100
  const clientsRemoved = [];