Get number of clients on Networked AFrame

319 Views Asked by At

I'm working on a little WebVR game using Hayden Lee's library, Networked AFrame and I'd like to place the users on a specific position as soon as they arrive in the networked room.

I've tried using the 'onConnect' callback, but when it's called the NAF object connectList is empty, so I cannot know if I'm the first one in the room or if other clients are already connected.

What would be the best way to get this kind of information, I can't find information about it in the docs.

Thanks for your help!

1

There are 1 best solutions below

1
On

Currently in Networked-Aframe you can only control the position of entities that you have created and there is not a mechanism for determining how many people are in the room.

The only way to do what you're suggesting with NAF 0.2.3 is to set an arbitrary wait period after the onConnect callback, say 10 seconds, in which you hope that all the other users connect to the room. If there are anomalies that take longer and you end up with a collision of two people choosing the same position you react to that collision (which is also hard given there isn't events for users connecting yet). NAF 0.3.0 will at least have events for other users joining.