How do I get the number of connections in the session? How do I get the number of connections in the session?

How do I get the number of connections in the session?

Maria Scieranska

Objective

Obtaining the number of connections in a session.

Applies To

  • Video API
  • Session Connections

Procedure

The session object dispatches a connectionCreated event for each client connected to the session. To count the number of connections in the session:

  1. Create a variable called numberOfConnections and initialize it to zero.
  2. Listen to the "connectionCreated" event and increment the variable numberOfConnections inside the event handler. The value of this variable then gives you the number of clients connected to the session at any instant of time.