Class: Room

Room

A Room represents communication between your Client and one or more Participants sharing AudioTracks and VideoTracks.

You can connect to a Room by calling Client#connect.


Properties:
Name Type Description
isRecording boolean

Whether or not the Room is being recorded

localParticipant LocalParticipant

Your Client's LocalParticipant in the Room.

name string

The Room's name

participants Map.<Participant.SID, Participant>

The Participants participating in this Room

sid Room.SID

The Room's SID

state string

"connected" or "disconnected"

Fires:

Methods


disconnect()

Disconnect from the Room.

Returns:
Type
this

getStats()

Get the Room's media statistics.

Returns:
Type
Promise.<Array.<StatsReport>>

Type Definitions


SID

A Room.SID is a 34-character string starting with "RM" that uniquely identifies a Room.

Type:
  • string

Events


disconnected

Your Client was disconnected from the Room and all other Participants.

Parameters:
Name Type Description
room Room

The Room your Client was disconnected from

Example
myRoom.on('disconnected', function() {
  myRoom.localParticipant.media.detach();
});

participantConnected

A Participant joined the Room.

Parameters:
Name Type Description
participant Participant

The Participant who joined

Example
myRoom.on('participantConnected', function(participant) {
  console.log(participant.identity + ' joined the Room');

  // Get the participant's Media,
  var participantMedia = participant.media;

  // And attach it to your application's view.
  var participantView = document.getElementById('participant-view');
  participantMedia.attach(participantView);
  participantVideos.appendChild(participantView);
});

participantDisconnected

A Participant left the Room.

Parameters:
Name Type Description
participant Participant

The Participant who left

Example
myRoom.on('participantDisconnected', function(participant) {
  console.log(participant.identity + ' left the Room');
});

recordingStarted

The Room is now being recorded


recordingStopped

The Room is no longer being recorded


trackAdded

A Track was added by a Participant in the Room.

Parameters:
Name Type Description
track Track

The Track that was added

participant Participant

The Participant who added the Track


trackDimensionsChanged

One of the Participant's VideoTrack's dimensions changed.

Parameters:
Name Type Description
track VideoTrack

The VideoTrack whose dimensions changed

participant Participant

The Participant whose VideoTrack's dimensions changed


trackDisabled

A Track was disabled by a Participant in the Room.

Parameters:
Name Type Description
track Track

The Track that was disabled

participant Participant

The Participant who disabled the Track


trackEnabled

A Track was enabled by a Participant in the Room.

Parameters:
Name Type Description
track Track

The Track that was enabled

participant Participant

The Participant who enabled the Track


trackRemoved

A Track was removed by a Participant in the Room.

Parameters:
Name Type Description
track Track

The Track that was removed

participant Participant

The Participant who removed the Track


trackStarted

One of a Participant's Tracks in the Room started.

Parameters:
Name Type Description
track Track

The Track that started

participant Participant

The Participant whose Track started