fix an issue where reconnecting label is displayed incorrectly

pull/1061/head
Ryan ZHAO 2 weeks ago
parent e36bf7a2f4
commit 9decf67b7a

@ -25,7 +25,6 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
public let mode: CallMode public let mode: CallMode
let contactName: String let contactName: String
var audioMode: AudioMode var audioMode: AudioMode
let isOutgoing: Bool
var remoteSDP: RTCSessionDescription? = nil { var remoteSDP: RTCSessionDescription? = nil {
didSet { didSet {
if hasStartedConnecting, let sdp = remoteSDP { if hasStartedConnecting, let sdp = remoteSDP {
@ -155,7 +154,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
// MARK: - Initialization // MARK: - Initialization
init(for sessionId: String, contactName: String, uuid: String, mode: CallMode, outgoing: Bool = false, using dependencies: Dependencies) { init(for sessionId: String, contactName: String, uuid: String, mode: CallMode, using dependencies: Dependencies) {
self.dependencies = dependencies self.dependencies = dependencies
self.sessionId = sessionId self.sessionId = sessionId
self.contactName = contactName self.contactName = contactName
@ -164,7 +163,6 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
self.mode = mode self.mode = mode
self.audioMode = .earpiece self.audioMode = .earpiece
self.webRTCSession = WebRTCSession.current ?? WebRTCSession(for: sessionId, with: uuid, using: dependencies) self.webRTCSession = WebRTCSession.current ?? WebRTCSession(for: sessionId, with: uuid, using: dependencies)
self.isOutgoing = outgoing
self.currentConnectionStep = (mode == .offer ? OfferStep.initializing : AnswerStep.receivedOffer) self.currentConnectionStep = (mode == .offer ? OfferStep.initializing : AnswerStep.receivedOffer)
self.connectionStepsRecord = [Bool](repeating: false, count: (mode == .answer ? 5 : 6)) self.connectionStepsRecord = [Bool](repeating: false, count: (mode == .answer ? 5 : 6))
WebRTCSession.current = self.webRTCSession WebRTCSession.current = self.webRTCSession
@ -466,13 +464,14 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
} }
public func reconnectIfNeeded() { public func reconnectIfNeeded() {
guard !self.hasEnded else { return }
setupTimeoutTimer() setupTimeoutTimer()
hasStartedReconnecting?() hasStartedReconnecting?()
guard isOutgoing else { return }
tryToReconnect() tryToReconnect()
} }
private func tryToReconnect() { private func tryToReconnect() {
guard self.mode == .offer else { return }
reconnectTimer?.invalidate() reconnectTimer?.invalidate()
// Register a callback to get the current network status then remove it immediately as we only // Register a callback to get the current network status then remove it immediately as we only

@ -78,7 +78,7 @@ extension SessionCallManager: CXProviderDelegate {
guard let call: SessionCall = (self.currentCall as? SessionCall) else { return } guard let call: SessionCall = (self.currentCall as? SessionCall) else { return }
call.webRTCSession.audioSessionDidActivate(audioSession) call.webRTCSession.audioSessionDidActivate(audioSession)
if call.isOutgoing && !call.hasConnected { CallRingTonePlayer.shared.startPlayingRingTone() } if call.mode == .offer && !call.hasConnected { CallRingTonePlayer.shared.startPlayingRingTone() }
} }
public func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) { public func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {

@ -186,7 +186,6 @@ extension ConversationVC:
contactName: self.viewModel.threadData.displayName, contactName: self.viewModel.threadData.displayName,
uuid: UUID().uuidString.lowercased(), uuid: UUID().uuidString.lowercased(),
mode: .offer, mode: .offer,
outgoing: true,
using: dependencies using: dependencies
) )
}) })

Loading…
Cancel
Save