[SOLVED] Orbiter getOccupants

All Union Platform questions, comments, feature requests, and bug reports.

Orbiter getOccupants  

Postby klapvee » Fri 03 May 2013 15:37

Hi,

i hope this is the right place for Orbiter questions. I dont know what is going on in Orbiter but it seems there is a bug with the getOccupants() function.
Currently i am working in a staging environment and i am testing it with 3 different browsers on 1 laptop. what i do is when the browser is done loading i connect the user
with union through Orbiter. After that i let the user join the room "limbo". When i look in the admin application, i see that there are 3 users indeed in the room.

And this is the weird thing: after i joined the room i request the room.getOccupants() and to be sure room.getNumOccupants(). They have suprising results!
Sometimes it's 1, sometimes 2 and if im lucky he sees all the users. But the results are really unpredictable.

is this a known issue?
klapvee
 
Posts: 4
Joined: Fri 03 May 2013 15:31

Re: Orbiter getOccupants

Postby colin » Fri 24 Jan 2014 23:19

hi klapvee,
it sounds like you might be checking room.getOccupants() before the client has finished synchronizing with the server. to be sure that the client has finished synchronization before you check getOccupants()/getNumOccupants(), use the Room class's getSyncState() method. once getSyncState() returns net.user1.orbiter. SynchronizationState.SYNCHRONIZED, getOccupants()/getNumOccupants() will return results based on the fully populated occupant list.

for example,

Code: Select all
if (room.getSyncState() == net.user1.orbiter.SynchronizationState.SYNCHRONIZED) {
  alert(room.getNumOccupants());
}


note that the preceding code isn't necessary from a RoomEvent.JOIN listener because a room joined by the current client is always fully synchronized before the RoomEvent.JOIN event occurs.

colin
colin
 
Posts: 232
Joined: Mon 17 Oct 2011 18:47


Return to Union Platform

Online

Users browsing this forum: No registered users and 12 guests