PeerConnectionClient thread safety.

pull/1/head
Matthew Chen 8 years ago
parent 729769afa7
commit 1a0347b782

@ -346,8 +346,6 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
return RTCMediaConstraints(mandatoryConstraints: mandatoryConstraints, optionalConstraints: nil) return RTCMediaConstraints(mandatoryConstraints: mandatoryConstraints, optionalConstraints: nil)
} }
// TODO: Review all .async
// TODO: Review all error == nil
public func createOffer() -> Promise<HardenedRTCSessionDescription> { public func createOffer() -> Promise<HardenedRTCSessionDescription> {
SwiftAssertIsOnMainThread(#function) SwiftAssertIsOnMainThread(#function)
@ -399,7 +397,6 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
} }
} }
// TODO: Review all promises
public func setLocalSessionDescriptionInternal(_ sessionDescription: HardenedRTCSessionDescription) -> Promise<Void> { public func setLocalSessionDescriptionInternal(_ sessionDescription: HardenedRTCSessionDescription) -> Promise<Void> {
return PromiseKit.wrap { [weak self] resolve in return PromiseKit.wrap { [weak self] resolve in
guard let strongSelf = self else { return } guard let strongSelf = self else { return }
@ -430,8 +427,8 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
Logger.verbose("\(strongSelf.logTag) setting local session description: \(sessionDescription)") Logger.verbose("\(strongSelf.logTag) setting local session description: \(sessionDescription)")
peerConnection.setLocalDescription(sessionDescription.rtcSessionDescription, peerConnection.setLocalDescription(sessionDescription.rtcSessionDescription,
completionHandler: { error in completionHandler: { error in
guard error == nil else { if let error = error {
reject(error!) reject(error)
return return
} }
fulfill() fulfill()
@ -473,8 +470,8 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD
Logger.verbose("\(strongSelf.logTag) setting remote description: \(sessionDescription)") Logger.verbose("\(strongSelf.logTag) setting remote description: \(sessionDescription)")
peerConnection.setRemoteDescription(sessionDescription, peerConnection.setRemoteDescription(sessionDescription,
completionHandler: { error in completionHandler: { error in
guard error == nil else { if let error = error {
reject(error!) reject(error)
return return
} }
fulfill() fulfill()

Loading…
Cancel
Save