add steps details

pull/1061/head
Ryan ZHAO 9 months ago
parent 69a565d14c
commit 35fdce7272

@ -85,7 +85,9 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
didSet {
stateDidChange?()
hasConnectedDidChange?()
updateCallDetailedStatus?("Call Connected")
updateCallDetailedStatus?(
mode == .offer ? Constants.call_connection_steps_sender[5] : Constants.call_connection_steps_receiver[4]
)
}
}
@ -210,6 +212,9 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
if hasStartedConnecting {
webRTCSession.handleRemoteSDP(sdp, from: sessionId) // This sends an answer message internally
}
if mode == .answer {
self.updateCallDetailedStatus?(Constants.call_connection_steps_receiver[0])
}
}
// MARK: - Actions
@ -250,7 +255,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
self.callInteractionId = interaction?.id
self.updateCallDetailedStatus?("Creating Call")
self.updateCallDetailedStatus?(Constants.call_connection_steps_sender[0])
try? webRTCSession
.sendPreOffer(
@ -263,7 +268,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
// Start the timeout timer for the call
.handleEvents(receiveOutput: { [weak self] _ in self?.setupTimeoutTimer() })
.flatMap { [weak self] _ in
self?.updateCallDetailedStatus?("Sending Call Offer")
self?.updateCallDetailedStatus?(Constants.call_connection_steps_sender[1])
return webRTCSession
.sendOffer(to: thread)
.retry(5)
@ -273,7 +278,6 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
switch result {
case .finished:
SNLog("[Calls] Offer message sent")
self?.updateCallDetailedStatus?("Sending Connection Candidates")
case .failure(let error):
SNLog("[Calls] Error initializing call after 5 retries: \(error), ending call...")
self?.handleCallInitializationFailed()
@ -289,7 +293,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
if let sdp = remoteSDP {
SNLog("[Calls] Got remote sdp already")
self.updateCallDetailedStatus?("Answering Call")
self.updateCallDetailedStatus?(Constants.call_connection_steps_receiver[1])
webRTCSession.handleRemoteSDP(sdp, from: sessionId) // This sends an answer message internally
}
}
@ -428,15 +432,27 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
isRemoteVideoEnabled = isEnabled
}
public func iceCandidateDidSend() {
public func sendingIceCandidates() {
DispatchQueue.main.async {
self.updateCallDetailedStatus?("Awaiting Recipient Answer...")
self.updateCallDetailedStatus?(
self.mode == .offer ? Constants.call_connection_steps_sender[2] : Constants.call_connection_steps_receiver[2]
)
}
}
public func iceCandidateDidSend() {
if self.mode == .offer {
DispatchQueue.main.async {
self.updateCallDetailedStatus?(Constants.call_connection_steps_sender[3])
}
}
}
public func iceCandidateDidReceive() {
DispatchQueue.main.async {
self.updateCallDetailedStatus?("Handling Connection Candidates")
self.updateCallDetailedStatus?(
self.mode == .offer ? Constants.call_connection_steps_sender[4] : Constants.call_connection_steps_receiver[3]
)
}
}

@ -12,6 +12,7 @@ public protocol WebRTCSessionDelegate: AnyObject {
func webRTCIsConnected()
func isRemoteVideoDidChange(isEnabled: Bool)
func sendingIceCandidates()
func iceCandidateDidSend()
func iceCandidateDidReceive()
func dataChannelDidOpen()
@ -300,6 +301,7 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
}
private func sendICECandidates() {
self.delegate?.sendingIceCandidates()
let candidates: [RTCIceCandidate] = self.queuedICECandidates
let uuid: String = self.uuid
let contactSessionId: String = self.contactSessionId

@ -8,4 +8,22 @@ public enum Constants {
public static let session_download_url: String = "https://getsession.org/download"
public static let gif: String = "GIF"
public static let oxen_foundation: String = "Oxen Foundation"
// TODO: Localize call connection steps
public static let call_connection_steps_sender: [String] = [
"Creating Call 1/6",
"Sending Call Offer 2/6",
"Sending Connection Candidates 3/6",
"Awaiting Recipient Answer... 4/6",
"Handling Connection Candidates 5/6",
"Call Connected 6/6",
]
public static let call_connection_steps_receiver: [String] = [
"Received Call Offer 1/5",
"Answering Call 2/5",
"Sending Connection Candidates 3/5",
"Handling Connection Candidates 4/5",
"Call Connected 5/5",
]
}

Loading…
Cancel
Save