Slide 120
Slide 120 text
1. Acquire LocalTracks
2. Connect to a Room
3. Handle Participants
4. Handle Participants’ Tracks
5. Disconnect
© 2017 TWILIO, INC. ALL RIGHTS RESERVED.
MAIN CONTENT AND SUPPORTING
TEXT
PROGRAMMABLE VIDEO FUNDAMENTALS
© 2017 TWILIO, INC. ALL RIGHTS RESERVED.
// 3. Handle Participants
room.participants.forEach(handleParticipant)
room.on(‘participantConnected’, handleParticipant)
function handleParticipant(participant) {
const { identity, sid } = participant
console.log(‘%s (%s) connected’, identity, sid)
addParticipantView(participant)
participant.once(‘disconnected’, () => {
console.log(‘%s disconnected’, identity)
removeParticipantView(participant)
})
// 4. Handle Participants’ Tracks
participant.tracks.forEach(handleTrackAdded)
participant.on(‘trackAdded’, handleTrackAdded)
}
JAVASCRIPT