teleportxr 1.0.9 → 1.0.11
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 +1 -0
- package/client/client_manager.js +2 -2
- package/client/geometry_service.js +14 -14
- package/connections/webrtcconnection.js +3 -0
- package/package.json +1 -1
- package/scene/scene.js +1 -0
- package/signaling.js +14 -11
package/client/client.js
CHANGED
package/client/client_manager.js
CHANGED
|
@@ -47,7 +47,7 @@ class ClientManager
|
|
|
47
47
|
error("Failed to create a root node for client "+clientID);
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
|
-
var sigCli=signaling.signalingClients
|
|
50
|
+
var sigCli=signaling.signalingClients.get(clientID);
|
|
51
51
|
var sigSend=sigCli.sendToClient.bind(sigCli);
|
|
52
52
|
var c=new client.Client(clientID,sigSend);
|
|
53
53
|
c.setOrigin(origin_uid);
|
|
@@ -97,7 +97,7 @@ class ClientManager
|
|
|
97
97
|
writeState() {
|
|
98
98
|
var content="<table><tr><th>Client Id</th><th>IP Address</th><th>Signalling State</th></tr>";
|
|
99
99
|
for (let [cl_id,cl] of this.clients) {
|
|
100
|
-
var sigCli=signaling.signalingClients
|
|
100
|
+
var sigCli=signaling.signalingClients.get(cl_id);
|
|
101
101
|
content+="\n<tr><td>"+cl_id+"</td> <td>" + sigCli.ip + "</td> <td>" + sigCli.signalingState + "</td></tr>";
|
|
102
102
|
};
|
|
103
103
|
content+="\n</table>";
|
|
@@ -27,30 +27,30 @@ class TrackedResource
|
|
|
27
27
|
this.acknowledged=new bit.BitSet(); // Whether the client acknowledged receiving the resource.
|
|
28
28
|
}
|
|
29
29
|
IsNeededByClient(clientID) {
|
|
30
|
-
return this.clientNeeds.get
|
|
30
|
+
return this.clientNeeds.get(clientIDToIndex.get(clientID));
|
|
31
31
|
}
|
|
32
32
|
WasSentToClient(clientID) {
|
|
33
|
-
return this.sent.get
|
|
33
|
+
return this.sent.get(clientIDToIndex.get(clientID));
|
|
34
34
|
}
|
|
35
35
|
WasAcknowledgedByClient(clientID) {
|
|
36
|
-
return this.acknowledged.get(clientIDToIndex
|
|
36
|
+
return this.acknowledged.get(clientIDToIndex.get(clientID));
|
|
37
37
|
}
|
|
38
38
|
GetTimeSent(clientID) {
|
|
39
|
-
return this.sent_server_time_us
|
|
39
|
+
return this.sent_server_time_us.get(clientID);
|
|
40
40
|
}
|
|
41
41
|
Sent(clientID,timestamp) {
|
|
42
|
-
this.sent.set(clientIDToIndex
|
|
43
|
-
this.acknowledged.set(clientIDToIndex
|
|
42
|
+
this.sent.set(clientIDToIndex.get(clientID),true);
|
|
43
|
+
this.acknowledged.set(clientIDToIndex.get(clientID),false);
|
|
44
44
|
this.sent_server_time_us.set(clientID,timestamp);
|
|
45
45
|
}
|
|
46
46
|
AcknowledgeBy(clientID) {
|
|
47
|
-
this.acknowledged.set(clientIDToIndex
|
|
47
|
+
this.acknowledged.set(clientIDToIndex.get(clientID),true);
|
|
48
48
|
// erase timestamp?
|
|
49
49
|
this.sent_server_time_us.delete(clientID);
|
|
50
50
|
}
|
|
51
51
|
Timeout(clientID) {
|
|
52
|
-
this.sent.set(clientIDToIndex
|
|
53
|
-
this.acknowledged.set(clientIDToIndex
|
|
52
|
+
this.sent.set(clientIDToIndex.get(clientID),false);
|
|
53
|
+
this.acknowledged.set(clientIDToIndex.get(clientID),false);
|
|
54
54
|
this.sent_server_time_us.clear(clientID);
|
|
55
55
|
}
|
|
56
56
|
};
|
|
@@ -92,6 +92,8 @@ class GeometryService
|
|
|
92
92
|
this.streamedFontAtlases=new Map();
|
|
93
93
|
|
|
94
94
|
this.backgroundTextureUid=0;
|
|
95
|
+
// ten seconds for timeout. Tweak this.
|
|
96
|
+
this.timeout_us=10000000;
|
|
95
97
|
}
|
|
96
98
|
SetScene(sc) {
|
|
97
99
|
this.scene=sc;
|
|
@@ -299,8 +301,6 @@ class GeometryService
|
|
|
299
301
|
|
|
300
302
|
UpdateNodesToStream()
|
|
301
303
|
{
|
|
302
|
-
// ten seconds for timeout. Tweak this.
|
|
303
|
-
const timeout_us=10000000;
|
|
304
304
|
// The set of ALL the nodes of sufficient priority that the client NEEDS is streamedNodes.
|
|
305
305
|
for(let uid of this.nodesToStreamEventually)
|
|
306
306
|
{
|
|
@@ -343,7 +343,7 @@ class GeometryService
|
|
|
343
343
|
{
|
|
344
344
|
var timeSentUs=res.GetTimeSent(this.clientID);
|
|
345
345
|
// If we sent it too long ago with no acknowledgement, we can send it again.
|
|
346
|
-
if(time_now_us-timeSentUs>timeout_us)
|
|
346
|
+
if(time_now_us-timeSentUs>this.timeout_us)
|
|
347
347
|
{
|
|
348
348
|
res.Timeout(this.clientID);
|
|
349
349
|
}
|
|
@@ -382,12 +382,11 @@ class GeometryService
|
|
|
382
382
|
// If it was already received we don't send it:
|
|
383
383
|
if(res.WasAcknowledgedByClient(this.clientID))
|
|
384
384
|
continue;
|
|
385
|
-
res.Sent(this.clientID,time_now_us);
|
|
386
385
|
if(res.WasSentToClient(this.clientID))
|
|
387
386
|
{
|
|
388
387
|
var timeSentUs=res.GetTimeSent(this.clientID);
|
|
389
388
|
// If we sent it too long ago with no acknowledgement, we can send it again.
|
|
390
|
-
if(time_now_us-timeSentUs>timeout_us)
|
|
389
|
+
if(time_now_us-timeSentUs>this.timeout_us)
|
|
391
390
|
{
|
|
392
391
|
res.Timeout(this.clientID);
|
|
393
392
|
}
|
|
@@ -396,6 +395,7 @@ class GeometryService
|
|
|
396
395
|
{
|
|
397
396
|
// if it hasn't been sent at all to our client, we add its resources.
|
|
398
397
|
resource_uids.push(uid);
|
|
398
|
+
res.Sent(this.clientID,time_now_us);
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
return resource_uids;
|
|
@@ -127,7 +127,10 @@ class WebRtcConnection extends EventEmitter
|
|
|
127
127
|
|
|
128
128
|
this.peerConnection.addEventListener('iceconnectionstatechange', onIceConnectionStateChange);
|
|
129
129
|
this.peerConnection.addEventListener('icegatheringstatechange', onIceGatheringStateChange);
|
|
130
|
+
this.peerConnection.addEventListener("icecandidateerror", (event) => {
|
|
130
131
|
|
|
132
|
+
console.log("ICE candidate error: "+str(event.errorCode)+" "+event.errorText+" "+event.port+" "+event.url);
|
|
133
|
+
});
|
|
131
134
|
|
|
132
135
|
const onConnectionStateChange = () =>
|
|
133
136
|
{
|
package/package.json
CHANGED
package/scene/scene.js
CHANGED
|
@@ -60,6 +60,7 @@ class Scene {
|
|
|
60
60
|
if (pose) {
|
|
61
61
|
n.pose.position = { x: pose.position[0], y: pose.position[1], z: pose.position[2] };
|
|
62
62
|
n.pose.orientation = { x: pose.orientation[0], y: pose.orientation[1], z: pose.orientation[2], w: pose.orientation[3] };
|
|
63
|
+
n.pose.scale = { x: pose.scale[0], y: pose.scale[1], z: pose.scale[2] };
|
|
63
64
|
}
|
|
64
65
|
const components = sub_obj["components"];
|
|
65
66
|
if (components) {
|
package/signaling.js
CHANGED
|
@@ -60,7 +60,7 @@ function sendResponseToClient(clientID) {
|
|
|
60
60
|
if (!signalingClients.has(clientID)) {
|
|
61
61
|
console.log("No client "+clientID+" found.");
|
|
62
62
|
} else {
|
|
63
|
-
var signalingClient=signalingClients
|
|
63
|
+
var signalingClient=signalingClients.get(clientID);
|
|
64
64
|
// First, we send the WebSockets signaling response.
|
|
65
65
|
var txt =
|
|
66
66
|
'{"teleport-signal-type":"request-response","content":{"clientID": ' +
|
|
@@ -96,7 +96,7 @@ function processInitialRequest(clientID, signalingClient, content) {
|
|
|
96
96
|
}
|
|
97
97
|
// identifies as a previous client. Discard the new client ID.
|
|
98
98
|
//TODO: we're taking the client's word for it that it is clientID. Some kind of token/hash?
|
|
99
|
-
signalingClients
|
|
99
|
+
signalingClients.set(clientID,signalingClient);
|
|
100
100
|
if (j_clientID != clientID) {
|
|
101
101
|
console.log(
|
|
102
102
|
"info: Remapped from " + clientID + " to " + j_clientID
|
|
@@ -106,36 +106,39 @@ function processInitialRequest(clientID, signalingClient, content) {
|
|
|
106
106
|
);
|
|
107
107
|
|
|
108
108
|
if (signalingClients.has(clientID)) {
|
|
109
|
-
signalingClients
|
|
109
|
+
signalingClients.delete(clientID);
|
|
110
110
|
clientUids.erase(clientID);
|
|
111
111
|
}
|
|
112
112
|
clientID = j_clientID;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
var ipAddr = signalingClient.ip_addr_port;
|
|
116
|
+
if (desiredIP.length != 0 && !ipAddr.contains(desiredIP))
|
|
117
|
+
return;
|
|
116
118
|
// Skip clients we have already added.
|
|
117
119
|
if (signalingClient.signalingState == SignalingState.START)
|
|
118
120
|
signalingClient.ChangeSignalingState(SignalingState.REQUESTED);
|
|
121
|
+
//Ignore connections from clients with the wrong IP, if a desired IP has been set.
|
|
119
122
|
// if signalingState is START, we should not have a client...
|
|
120
|
-
if (signalingClient.
|
|
123
|
+
if (signalingClient.signalingState==SignalingState.ACCEPTED||signalingClient.signalingState==SignalingState.STREAMING)
|
|
124
|
+
{
|
|
121
125
|
// ok, we've received a connection request from a client that WE think we already have.
|
|
122
126
|
// Apparently the CLIENT thinks they've disconnected.
|
|
123
127
|
// The client might, as far as we know, have lost the information it needs to continue the connection.
|
|
124
128
|
// Therefore we should resend everything required.
|
|
125
|
-
signalingClient.ChangeSignalingState(SignalingState.STREAMING);
|
|
129
|
+
//signalingClient.ChangeSignalingState(SignalingState.STREAMING);
|
|
126
130
|
console.log(
|
|
127
131
|
"Warning: Client " +
|
|
128
132
|
clientID +
|
|
129
133
|
" reconnected, but we didn't know we'd lost them."
|
|
130
134
|
);
|
|
131
135
|
// It may be just that the connection request was already in flight when we accepted its predecessor.
|
|
132
|
-
sendResponseToClient(clientID);
|
|
136
|
+
//sendResponseToClient(clientID);
|
|
137
|
+
startStreaming(signalingClient);
|
|
133
138
|
return;
|
|
134
139
|
}
|
|
135
|
-
if (signalingClient.signalingState
|
|
136
|
-
|
|
137
|
-
//Ignore connections from clients with the wrong IP, if a desired IP has been set.
|
|
138
|
-
if (desiredIP.length == 0 || ipAddr.contains(desiredIP)) {
|
|
140
|
+
if (signalingClient.signalingState==SignalingState.REQUESTED)
|
|
141
|
+
{
|
|
139
142
|
startStreaming(signalingClient);
|
|
140
143
|
}
|
|
141
144
|
}
|
|
@@ -252,7 +255,7 @@ exports.sendConfigMessage = function (clientID, msg) {
|
|
|
252
255
|
|
|
253
256
|
if (signalingClients.has(clientID)) {
|
|
254
257
|
console.log("sendConfigMessage to "+clientID+": "+msg);
|
|
255
|
-
signalingClients
|
|
258
|
+
signalingClients.get(clientID).ws.send(escapedStr);
|
|
256
259
|
} else {
|
|
257
260
|
console.log(
|
|
258
261
|
"sendConfigMessage with clientID " +
|