Skip to content

Commit

Permalink
New tools now initialize properly on slow networks, previous method s…
Browse files Browse the repository at this point in the history
…ent subscribe method before socket was ready, resulting in no subscription being created
  • Loading branch information
dangond-ptc committed Feb 29, 2024
1 parent c600f0a commit 0b3f7e4
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions libraries/objectDefaultFiles/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,20 +909,22 @@
* Subscribes this socket to data values being written to nodes on this frame
*/
this.sendRealityEditorSubscribe = function () {
var timeoutFunction = function() {
if (spatialObject.object) {
self.ioObject.emit(getIoTitle('/subscribe/realityEditor'), JSON.stringify({
object: spatialObject.object,
frame: spatialObject.frame,
protocol: spatialObject.protocol
}));
let timeout = 10;
function subscribe() {
if (self.ioObject.socket.readyState !== self.ioObject.socket.OPEN) {
if (timeout < 1000) {
timeout *= 10;
}
setTimeout(subscribe, timeout);
return;
}
};
// Call it a few times to help ensure it succeeds
setTimeout(timeoutFunction, 10);
setTimeout(timeoutFunction, 50);
setTimeout(timeoutFunction, 100);
setTimeout(timeoutFunction, 1000);
self.ioObject.emit(getIoTitle('/subscribe/realityEditor'), JSON.stringify({
object: spatialObject.object,
frame: spatialObject.frame,
protocol: spatialObject.protocol
}));
}
subscribe();
};
this.sendRealityEditorSubscribe();

Expand Down

0 comments on commit 0b3f7e4

Please sign in to comment.