fix: Handle error when writing new ICE candidate to WebRTC signaling channel

This commit is contained in:
Adam Shiervani 2025-04-08 15:27:51 +02:00 committed by Siyuan Miao
parent 3c973ed272
commit f17f15be57
1 changed files with 4 additions and 1 deletions

View File

@ -144,7 +144,10 @@ func newSession(config SessionConfig) (*Session, error) {
peerConnection.OnICECandidate(func(candidate *webrtc.ICECandidate) {
logger.Infof("Our WebRTC peerConnection has a new ICE candidate: %v", candidate)
if candidate != nil {
wsjson.Write(context.Background(), config.ws, gin.H{"type": "new-ice-candidate", "data": candidate.ToJSON()})
err := wsjson.Write(context.Background(), config.ws, gin.H{"type": "new-ice-candidate", "data": candidate.ToJSON()})
if err != nil {
logger.Errorf("failed to write new-ice-candidate to WebRTC signaling channel: %v", err)
}
}
})