Skip to content

Instantly share code, notes, and snippets.

@quangtqag
Created May 11, 2019 01:41
Show Gist options
  • Save quangtqag/886a26c2f80902eeb298736de035e617 to your computer and use it in GitHub Desktop.
Save quangtqag/886a26c2f80902eeb298736de035e617 to your computer and use it in GitHub Desktop.
@IBAction func endCall(_ sender: Any) {
self.signalClient.deleteSdpAndCandidate(for: self.currentPerson)
self.webRTCClient.closePeerConnection()
self.webRTCClient.createPeerConnection()
self.hasLocalSdp = false
self.localCandidateCount = 0
self.hasRemoteSdp = false
self.remoteCandidateCount = 0
}
func deleteSdpAndCandidate(for person: String) {
Firestore.firestore().collection(person).document("sdp").delete() { err in
if let err = err {
print("Error removing firestore sdp: \(err)")
} else {
print("Firestore sdp successfully removed!")
}
}
Firestore.firestore().collection(person).document("candidate").delete() { err in
if let err = err {
print("Error removing firestore candidate: \(err)")
} else {
print("Firestore candidate successfully removed!")
}
}
}
func closePeerConnection() {
self.peerConnection!.close()
self.peerConnection = nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment