WebRTC-iOS
WebRTC-iOS copied to clipboard
Signaling server via firebase firestore
I'm trying to use Firestore for a signaling server, and I want to explain how I solved the problem i had:
When we click the Offer button, an SDP is created, but it does not contain any candidates. After 1-2 seconds, candidates are created and localDescription is updated without our knowledge. The problem is that we send already an SDP to the other user that does not contain candidates.
My not-so-smart solution:
self.webRTCClient.offer { (_) in
DispatchQueue.main.asyncAfter(deadline: .now()+1) { // maybe 2 seconds delay better
self.webRTCClient.offer { (sdp) in
self.send(sdp: sdp)
}
}
}
This problem also occurs when we click the Answer button. The initially created SDP does not contain any candidates. Therefore, we need to add a similar logic there as well:
self.webRTCClient.answer { (_) in
DispatchQueue.main.asyncAfter(deadline: .now()+1) {
self.hasLocalSdp = true
if let localSdp = self.webRTCClient.peerConnection.localDescription {
self.send(sdp: localSdp)
}
}
}