teleportxr 1.0.50 → 1.0.52
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 -4
- package/client/client_manager.js +1 -1
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -54,7 +54,15 @@ class Client {
|
|
|
54
54
|
this.currentOriginState=new OriginState();
|
|
55
55
|
this.currentLightingState=new LightingState();
|
|
56
56
|
this.next_ack_id=BigInt(1);
|
|
57
|
+
this.clientStartMs=Date.now();
|
|
58
|
+
this.webRtcConnectedAtMs=0;
|
|
57
59
|
}
|
|
60
|
+
elapsedMsSinceStart(){
|
|
61
|
+
return Date.now()-this.clientStartMs;
|
|
62
|
+
}
|
|
63
|
+
elapsedMsSinceConnected(){
|
|
64
|
+
return this.webRtcConnectedAtMs?Date.now()-this.webRtcConnectedAtMs:-1;
|
|
65
|
+
}
|
|
58
66
|
tick(timestamp){
|
|
59
67
|
this.geometryService.GetNodesToSend();
|
|
60
68
|
}
|
|
@@ -62,11 +70,16 @@ class Client {
|
|
|
62
70
|
{
|
|
63
71
|
//this.webRtcConnection=wrtcConn;
|
|
64
72
|
// This should have come from our own existing webRtcConnection and nowhere else.
|
|
65
|
-
console.log("Connection state is "+newState.toString());
|
|
73
|
+
console.log("[T+"+this.elapsedMsSinceStart()+"ms] Connection state is "+newState.toString());
|
|
66
74
|
if(newState=="connected")
|
|
67
75
|
{
|
|
68
76
|
//this.webRtcConnection.sendGeometry("test");
|
|
69
77
|
this.webRtcConnected=true;
|
|
78
|
+
this.webRtcConnectedAtMs=Date.now();
|
|
79
|
+
console.log("[T+"+this.elapsedMsSinceStart()+"ms] WebRTC CONNECTED for client "+this.clientID+" — triggering immediate UpdateStreaming tick.");
|
|
80
|
+
// Kick an immediate tick so SetOriginNode and the first resource batch are
|
|
81
|
+
// sent without waiting for the next periodic interval (up to 1000 ms away).
|
|
82
|
+
setImmediate(this.UpdateStreaming.bind(this));
|
|
70
83
|
}
|
|
71
84
|
else
|
|
72
85
|
{
|
|
@@ -147,6 +160,8 @@ class Client {
|
|
|
147
160
|
// In Start() we send the SetupCommand.
|
|
148
161
|
Start()
|
|
149
162
|
{
|
|
163
|
+
this.clientStartMs=Date.now();
|
|
164
|
+
console.log("[T+0ms] Client.Start() — sending SetupCommand for client "+this.clientID);
|
|
150
165
|
this.setupCommand=new command.SetupCommand();
|
|
151
166
|
this.clientDynamicLighting=new core.ClientDynamicLighting();
|
|
152
167
|
// Session is (re)starting; the client has zero state, so retract any
|
|
@@ -224,6 +239,7 @@ class Client {
|
|
|
224
239
|
// We call StartStreaming once the SetupCommand has been acknowledged.
|
|
225
240
|
StartStreaming()
|
|
226
241
|
{
|
|
242
|
+
console.log("[T+"+this.elapsedMsSinceStart()+"ms] Client.StartStreaming() — creating WebRTC connection for client "+this.clientID);
|
|
227
243
|
this.webRtcConnectionManager=WebRtcConnectionManager.getInstance();
|
|
228
244
|
// We make sure WebRTC has a connection for this client.
|
|
229
245
|
this.webRtcConnection = this.webRtcConnectionManager.createConnection(
|
|
@@ -251,8 +267,10 @@ class Client {
|
|
|
251
267
|
return;
|
|
252
268
|
}
|
|
253
269
|
var msg =new message.AcknowledgementMessage();
|
|
254
|
-
|
|
255
|
-
|
|
270
|
+
// data arrives from the WebSocket signaling channel as a Node Buffer (Uint8Array view over a pooled
|
|
271
|
+
// ArrayBuffer), so we must wrap its underlying buffer using byteOffset/byteLength rather than passing
|
|
272
|
+
// the Buffer directly to DataView.
|
|
273
|
+
var dataView =new DataView(data.buffer,data.byteOffset,data.byteLength);
|
|
256
274
|
core.decodeFromDataView(msg,dataView,0);
|
|
257
275
|
if(msg.uint64_ackId==this.currentOriginState.ackId)
|
|
258
276
|
{
|
|
@@ -304,6 +322,7 @@ class Client {
|
|
|
304
322
|
return;
|
|
305
323
|
if(!this.webRtcConnected)
|
|
306
324
|
return;
|
|
325
|
+
console.log("[T+"+this.elapsedMsSinceStart()+"ms, conn+"+this.elapsedMsSinceConnected()+"ms] UpdateStreaming tick for client "+this.clientID);
|
|
307
326
|
var timestamp=core.getTimestampUs();
|
|
308
327
|
// Establish which nodes the client should have, and their resources.
|
|
309
328
|
// Then: which resources we think it does not yet have. Send those.
|
|
@@ -393,7 +412,7 @@ class Client {
|
|
|
393
412
|
this.currentOriginState.acknowledged=false;
|
|
394
413
|
this.currentOriginState.serverTimeSentUs=core.getTimestampUs();
|
|
395
414
|
console.log("\n===== NODE SERVER SENDING SETORIGINCOMMAND =====");
|
|
396
|
-
console.log("Sending SetOriginNodeCommand with origin uid "+setp.uint64_originNodeUid+" and ackId "+setp.uint64_ackId);
|
|
415
|
+
console.log("[T+"+this.elapsedMsSinceStart()+"ms, conn+"+this.elapsedMsSinceConnected()+"ms] Sending SetOriginNodeCommand with origin uid "+setp.uint64_originNodeUid+" and ackId "+setp.uint64_ackId);
|
|
397
416
|
console.log("\n===== END SETORIGINCOMMAND =====");
|
|
398
417
|
this.SendCommand(setp);
|
|
399
418
|
}
|
package/client/client_manager.js
CHANGED
|
@@ -22,7 +22,7 @@ class ClientManager
|
|
|
22
22
|
this.geometryIntervalId = setInterval(_.bind( function() {
|
|
23
23
|
//console.log("Streaming Update at "+core.getTimestampUs()/1000000.0);
|
|
24
24
|
this.UpdateStreaming();
|
|
25
|
-
},this),
|
|
25
|
+
},this), 1000);
|
|
26
26
|
}
|
|
27
27
|
StopStreaming(){
|
|
28
28
|
if(this.geometryIntervalId!=0)
|
package/package.json
CHANGED