Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't retrieve the number of users #12

Open
ilyen85 opened this issue May 14, 2019 · 4 comments
Open

Can't retrieve the number of users #12

ilyen85 opened this issue May 14, 2019 · 4 comments

Comments

@ilyen85
Copy link

ilyen85 commented May 14, 2019

Hi!

I would like to ask for some help on retrieving the number of users in the room. I'm using the WebRTC tutorial here

There is a part where we call startWebRTC function based on the number of members in the room.

room.on('members', members => {
   if (members.length >= 3) {
     return alert('The room is full');
   }
   // If we are the second user to connect to the room we will be creating the offer
   const isOfferer = members.length === 2;
   startWebRTC(isOfferer);
   startListentingToSignals();
 });

I might have missunderstood the documentation, I thought this listener will retrieve every member in the room.

When I log out the room and the members variable provided by the listener I get these:
room:

Room {
   name: "observable-REMOVED"
   scaledrone: Scaledrone {args: Arguments(1), originalInstance: Scaledrone, readyState: 2, callbackId: 2, callbacks: {…}, …}
   _cache: [{…}]
   _events: {
      data: [{…}]
      member_join: [{…}]
      members: Array(5)
         0: {callback: ƒ, context: undefined, ctx: Room}
         1: {callback: ƒ, context: undefined, ctx: Room}
         2: {callback: ƒ, context: undefined, ctx: Room}
         3: {callback: ƒ, context: undefined, ctx: Room}
         4: {callback: ƒ, context: undefined, ctx: Room}
...

As you can see here, there is 5 ppl in the room already, while the event listener will log this:
members array in the listener

MEMBERS:
0: {id: "BlrBA6qWpK"}
length: 1
__proto__: Array(0)

Can you please help me out with this one? Is there any other way to retrieve the number of users in the room?

Also forgot to mention that I can see the connected members if I visit my scaledrone dashboard.

Thanks!

@wbashir
Copy link

wbashir commented Aug 1, 2019

@ilyen85 did you ever figure this out?

@ilyen85
Copy link
Author

ilyen85 commented Aug 3, 2019

Hi, sadly no. Not using this library anymore, it was unpredictable.

@ryscript
Copy link

Hi @ilyen85 , May I know what Signaling server you prefer over to this one? Thanks

@herkyl
Copy link
Member

herkyl commented Mar 28, 2020

The members event provides the list of users who are connected at the time of connection. Use member_join and member_leave to catch any users joining or leaving.

It's hard to say what might have gone wrong in your situation. The room._events.members is an internal, I'm not sure that it contained a list of 5 users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants