Skip to content

Can't retrieve the number of users #12

Description

@ilyen85

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions