teleportxr 1.0.69 → 1.0.70
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())
|
package/client/client_manager.js
CHANGED
|
@@ -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
|
@@ -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 = [];
|