Properties:
| Name | Type | Argument | Description |
|---|---|---|---|
dominantSpeaker |
RemoteParticipant |
<nullable> |
The Dominant Speaker in the Room, if any |
isRecording |
boolean | Whether or not the Room is being recorded |
|
localParticipant |
LocalParticipant | Your LocalParticipant in the Room |
|
name |
string | The Room's name |
|
participants |
Map.<Participant.SID, RemoteParticipant> | The RemoteParticipants participating in this Room |
|
sid |
Room.SID | The Room's SID |
|
state |
string | "connected", "reconnecting", or "disconnected" |
Fires:
- Room#event:disconnected
- Room#event:participantConnected
- Room#event:participantDisconnected
- Room#event:reconnected
- Room#event:reconnecting
- Room#event:recordingStarted
- Room#event:recordingStopped
- Room#event:trackAdded
- Room#event:trackDimensionsChanged
- Room#event:trackDisabled
- Room#event:trackEnabled
- Room#event:trackMessage
- Room#event:trackPublished
- Room#event:trackRemoved
- Room#event:trackStarted
- Room#event:trackSubscribed
- Room#event:trackUnpublished
- Room#event:trackUnsubscribed
Throws:
Extends
- EventEmitter
Methods
-
disconnect()
-
Disconnect from the Room.
Returns:
- Type
- this
-
getStats()
-
Get the Room's media statistics. This is not supported in Safari 12.0 or below due to this bug : https://bugs.webkit.org/show_bug.cgi?id=192601
Returns:
- Type
- Promise.<Array.<StatsReport>>
Type Definitions
-
SID
-
Type:
- string
Events
-
disconnected
-
Your LocalParticipant was disconnected from the Room and all other RemoteParticipants.
Parameters:
Name Type Argument Description roomRoom The Room your LocalParticipant was disconnected from
errorTwilioError <nullable>
Present when the LocalParticipant got disconnected from the Room unexpectedly
Example
myRoom.on('disconnected', function(room, error) { if (error) { console.log('Unexpectedly disconnected:', error); } myRoom.localParticipant.tracks.forEach(function(track) { track.stop(); track.detach(); }); }); -
dominantSpeakerChanged
-
The Dominant Speaker in the Room changed. Either the Dominant Speaker is a new RemoteParticipant or the Dominant Speaker has been reset and is now null.
Parameters:
Name Type Argument Description dominantSpeakerRemoteParticipant <nullable>
The Dominant Speaker in the Room, if any
-
participantConnected
-
A RemoteParticipant joined the Room.
Parameters:
Name Type Description participantRemoteParticipant The RemoteParticipant who joined
Example
myRoom.on('participantConnected', function(participant) { console.log(participant.identity + ' joined the Room'); }); -
participantDisconnected
-
A RemoteParticipant left the Room.
Parameters:
Name Type Description participantRemoteParticipant The RemoteParticipant who left
Example
myRoom.on('participantDisconnected', function(participant) { console.log(participant.identity + ' left the Room'); participant.tracks.forEach(function(track) { track.detach().forEach(function(mediaElement) { mediaElement.remove(); }); }); }); -
reconnected
-
Your application successfully reconnected to the Room. When this event is emitted, the Room is in state "connected".
Example
myRoom.on('reconnected', () => { console.log('Reconnected!'); }); -
reconnecting
-
Your application is reconnecting to the Room. Typically this happens when there is a disruption in your media connection. When this event is emitted, the Room is in state "reconnecting". If reconnecting succeeds, the Room will emit a "reconnected" event.
Parameters:
Name Type Description errorTwilioError A TwilioError explaining why your application is reconnecting
Example
myRoom.on('reconnecting', error => { console.warn('Reconnecting!', error); }); -
recordingStarted
-
The Room is now being recorded
-
recordingStopped
-
The Room is no longer being recorded
-
trackAdded
-
A RemoteTrack was added by a RemoteParticipant in the Room.
Parameters:
Name Type Description trackRemoteTrack The RemoteTrack that was added
participantRemoteParticipant The RemoteParticipant who added the RemoteTrack
- Deprecated:
-
- Use RemoteParticipant#trackSubscribed instead
Example
room.on('trackAdded', function(track, participant) { var participantView = document.getElementById('participant-view-' + participant.identity); participantView.appendChild(track.attach()); }); -
trackDimensionsChanged
-
One of the RemoteParticipant's VideoTrack's dimensions changed.
Parameters:
Name Type Description trackRemoteVideoTrack The RemoteVideoTrack whose dimensions changed
participantRemoteParticipant The RemoteParticipant whose RemoteVideoTrack's dimensions changed
-
trackDisabled
-
A RemoteTrack was disabled by a RemoteParticipant in the Room.
Parameters:
Name Type Description trackRemoteTrack The RemoteTrack that was disabled
participantRemoteParticipant The RemoteParticipant who disabled the RemoteTrack
-
trackEnabled
-
A RemoteTrack was enabled by a RemoteParticipant in the Room.
Parameters:
Name Type Description trackRemoteTrack The RemoteTrack that was enabled
participantRemoteParticipant The RemoteParticipant who enabled the RemoteTrack
-
trackMessage
-
A message was received over one of the RemoteParticipant's RemoteDataTrack's.
Parameters:
Name Type Description datastring | ArrayBuffer trackRemoteVideoTrack The RemoteDataTrack over which the message was received
participantRemoteParticipant The RemoteParticipant whose RemoteDataTrack received the message
-
trackPublished
-
A RemoteTrack was published by a RemoteParticipant after connecting to the Room. This event is not emitted for RemoteTracks that were published while the RemoteParticipant was connecting to the Room.
Parameters:
Name Type Description publicationRemoteTrackPublication The RemoteTrackPublication which represents the published RemoteTrack
participantRemoteParticipant The RemoteParticipant who published the RemoteTrack
Example
function trackPublished(publication, participant) { console.log(`RemoteParticipant ${participant.sid} published Track ${publication.trackSid}`); } // Handle RemoteTracks published after connecting to the Room. room.on('trackPublished', trackPublished); room.on('participantConnected', participant => { // Handle RemoteTracks published while connecting to the Room. participant.trackPublications.forEach(publication => trackPublished(publication, participant)); }); -
trackRemoved
-
A RemoteTrack was removed by a RemoteParticipant in the Room.
Parameters:
Name Type Description trackRemoteTrack The RemoteTrack that was removed
participantRemoteParticipant The RemoteParticipant who removed the RemoteTrack
- Deprecated:
-
- Use RemoteParticipant#trackUnsubscribed instead
Example
room.on('trackRemoved', function(track, participant) { track.detach().forEach(function(mediaElement) { mediaElement.remove(); }); }); -
trackStarted
-
One of a RemoteParticipant's RemoteTracks in the Room started.
Parameters:
Name Type Description trackRemoteTrack The RemoteTrack that started
participantRemoteParticipant The RemoteParticipant whose RemoteTrack started
-
trackSubscribed
-
A RemoteParticipant's RemoteTrack was subscribed to.
Parameters:
Name Type Description trackRemoteTrack The RemoteTrack that was subscribed
participantRemoteParticipant The RemoteParticipant whose RemoteTrack was subscribed
Example
room.on('trackSubscribed', function(track, participant) { var participantView = document.getElementById('participant-view-' + participant.identity); participantView.appendChild(track.attach()); }); -
trackSubscriptionFailed
-
A RemoteParticipant's RemoteTrack could not be subscribed to.
Parameters:
Name Type Description errorTwilioError The reason the RemoteTrack could not be subscribed to
publicationRemoteTrackPublication The RemoteTrackPublication for the RemoteTrack that could not be subscribed to
participantRemoteParticipant The RemoteParticipant whose RemoteTrack could not be subscribed to
-
trackUnpublished
-
A RemoteTrack was unpublished by a RemoteParticipant to the Room.
Parameters:
Name Type Description publicationRemoteTrackPublication The RemoteTrackPublication which represents the unpublished RemoteTrack
participantRemoteParticipant The RemoteParticipant who unpublished the RemoteTrack
-
trackUnsubscribed
-
A RemoteParticipant's RemoteTrack was unsubscribed from.
Parameters:
Name Type Description trackRemoteTrack The RemoteTrack that was unsubscribed
participantRemoteParticipant The RemoteParticipant whose RemoteTrack was unsubscribed
Example
room.on('trackUnsubscribed', function(track, participant) { track.detach().forEach(function(mediaElement) { mediaElement.remove(); }); });