add retry for call messages

pull/1061/head
Ryan ZHAO 4 months ago
parent 47f9984d33
commit 8bc40a3535

@ -256,10 +256,25 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
interactionId: interaction?.id,
in: thread
)
.retry(5)
// Start the timeout timer for the call
.handleEvents(receiveOutput: { [weak self] _ in self?.setupTimeoutTimer() })
.flatMap { _ in webRTCSession.sendOffer(to: thread) }
.sinkUntilComplete()
.flatMap { _ in
webRTCSession
.sendOffer(to: thread)
.retry(5)
}
.sinkUntilComplete(
receiveCompletion: { [weak self] result in
switch result {
case .finished:
SNLog("[Calls] Offer message sent")
case .failure(let error):
SNLog("[Calls] Error initializing call after 5 retries: \(error), ending call...")
self?.handleCallInitializationFailed()
}
}
)
}
func answerSessionCall() {
@ -292,6 +307,11 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
hasEnded = true
}
func handleCallInitializationFailed() {
self.endSessionCall()
Singleton.callManager.reportCurrentCallEnded(reason: nil)
}
// MARK: - Call Message Handling
public func updateCallMessage(mode: EndCallMode, using dependencies: Dependencies) {

@ -22,7 +22,9 @@ extension WebRTCSession {
else {
guard sdp.type == .offer else { return }
self?.sendAnswer(to: sessionId).sinkUntilComplete()
self?.sendAnswer(to: sessionId)
.retry(5)
.sinkUntilComplete()
}
})
}

@ -375,6 +375,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
MessageSender
.sendImmediate(data: preparedSendData, using: dependencies)
.subscribe(on: DispatchQueue.global(qos: .userInitiated))
.retry(5)
.sinkUntilComplete()
}

Loading…
Cancel
Save