Created
May 11, 2019 01:33
-
-
Save quangtqag/ba57109a74bbd5ce42907311cd172cc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func send(candidate rtcIceCandidate: RTCIceCandidate, to person: String) { | |
do { | |
let dataMessage = try self.encoder.encode(IceCandidate(from: rtcIceCandidate)) | |
let dict = try JSONSerialization.jsonObject(with: dataMessage, options: .allowFragments) as! [String: Any] | |
Firestore.firestore() | |
.collection(person) | |
.document("candidate") | |
.collection("candidates") | |
.addDocument(data: dict) { (err) in | |
if let err = err { | |
print("Error send candidate: \(err)") | |
} else { | |
print("Candidate sent!") | |
} | |
} | |
} | |
catch { | |
debugPrint("Warning: Could not encode candidate: \(error)") | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment