Skip to content

Commit

Permalink
fix: blocking state candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricve committed Nov 23, 2023
1 parent 54bc198 commit e74facf
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions machinery/src/webrtc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ func (w WebRTC) CreateOffer(sd []byte) pionWebRTC.SessionDescription {
func RegisterCandidates(key string, candidate models.ReceiveHDCandidatesPayload) {
// Set lock
CandidatesMutex.Lock()
channel := CandidateArrays[key]
if channel == nil {
channel = make(chan string)
CandidateArrays[key] = channel
_, ok := CandidateArrays[key]
if !ok {
CandidateArrays[key] = make(chan string)
}
log.Log.Info("HandleReceiveHDCandidates: " + candidate.Candidate)
channel <- candidate.Candidate
select {
case CandidateArrays[key] <- candidate.Candidate:
default:
log.Log.Info("HandleReceiveHDCandidates: channel is full.")
}
CandidatesMutex.Unlock()
}

Expand Down Expand Up @@ -193,6 +196,8 @@ func InitializeWebRTCConnection(configuration *models.Configuration, communicati
log.Log.Error("InitializeWebRTCConnection: something went wrong while adding candidate: " + candidateErr.Error())
}
}
} else if connectionState == pionWebRTC.ICEConnectionStateFailed {

}
log.Log.Info("InitializeWebRTCConnection: connection state changed to: " + connectionState.String())
log.Log.Info("InitializeWebRTCConnection: Number of peers connected (" + strconv.FormatInt(peerConnectionCount, 10) + ")")
Expand Down

0 comments on commit e74facf

Please sign in to comment.