use synchronized GetParticipants to ensure eliminate timing issues upon participant join

This commit is contained in:
David Zhao
2021-01-31 23:06:48 -08:00
parent 014610bb05
commit 712d0da6cc
5 changed files with 12 additions and 21 deletions
+2 -2
View File
@@ -98,13 +98,13 @@ func (r *Room) Join(participant types.Participant) error {
// it's important to set this before connection, we don't want to miss out on any publishedTracks
participant.OnTrackPublished(r.onTrackAdded)
participant.OnStateChange(func(p types.Participant, oldState livekit.ParticipantInfo_State) {
logger.Debugw("participant state changed", "state", p.State(), "participant", p.ID(),
logger.Debugw("participant state changed", "state", p.State(), "participant", p.Identity(),
"oldState", oldState)
r.broadcastParticipantState(p)
if oldState == livekit.ParticipantInfo_JOINING && p.State() == livekit.ParticipantInfo_JOINED {
// subscribe participant to existing publishedTracks
for _, op := range r.participants {
for _, op := range r.GetParticipants() {
if p.ID() == op.ID() {
// don't send to itself
continue