End outgoing call with "No Answer" after 2 minutes
// FREEBIE
This commit is contained in:
parent
59059bc06c
commit
108720c2e7
|
@ -77,8 +77,8 @@ enum CallError: Error {
|
|||
case timeout(description: String)
|
||||
}
|
||||
|
||||
// FIXME TODO do we need to timeout?
|
||||
fileprivate let timeoutSeconds = 60
|
||||
// Should be roughly synced with Android client for consistency
|
||||
fileprivate let timeoutSeconds = 120
|
||||
|
||||
// All Observer methods will be invoked from the main thread.
|
||||
protocol CallServiceObserver: class {
|
||||
|
@ -311,6 +311,17 @@ protocol CallServiceObserver: class {
|
|||
let callMessage = OWSOutgoingCallMessage(thread: thread, offerMessage: offerMessage)
|
||||
return self.messageSender.sendCallMessage(callMessage)
|
||||
}
|
||||
}.then {
|
||||
let (callConnectedPromise, fulfill, _) = Promise<Void>.pending()
|
||||
self.fulfillCallConnectedPromise = fulfill
|
||||
|
||||
// Don't let the outgoing call ring forever. We don't support inbound ringing forever anyway.
|
||||
let timeout: Promise<Void> = after(interval: TimeInterval(timeoutSeconds)).then { () -> Void in
|
||||
// rejecting a promise by throwing is safely a no-op if the promise has already been fulfilled
|
||||
throw CallError.timeout(description: "timed out waiting to receive call answer")
|
||||
}
|
||||
|
||||
return race(timeout, callConnectedPromise)
|
||||
}.catch { error in
|
||||
Logger.error("\(self.TAG) placing call failed with error: \(error)")
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@ enum CallState: String {
|
|||
case remoteBusy // terminal
|
||||
}
|
||||
|
||||
enum CallDirection {
|
||||
case outgoing, incoming
|
||||
}
|
||||
|
||||
// All Observer methods will be invoked from the main thread.
|
||||
protocol CallObserver: class {
|
||||
func stateDidChange(call: SignalCall, state: CallState)
|
||||
|
@ -40,6 +44,8 @@ protocol CallObserver: class {
|
|||
// Signal Service identifier for this Call. Used to coordinate the call across remote clients.
|
||||
let signalingId: UInt64
|
||||
|
||||
let direction: CallDirection
|
||||
|
||||
// Distinguishes between calls locally, e.g. in CallKit
|
||||
let localId: UUID
|
||||
|
||||
|
@ -105,7 +111,8 @@ protocol CallObserver: class {
|
|||
|
||||
// MARK: Initializers and Factory Methods
|
||||
|
||||
init(localId: UUID, signalingId: UInt64, state: CallState, remotePhoneNumber: String) {
|
||||
init(direction: CallDirection, localId: UUID, signalingId: UInt64, state: CallState, remotePhoneNumber: String) {
|
||||
self.direction = direction
|
||||
self.localId = localId
|
||||
self.signalingId = signalingId
|
||||
self.state = state
|
||||
|
@ -113,11 +120,11 @@ protocol CallObserver: class {
|
|||
}
|
||||
|
||||
class func outgoingCall(localId: UUID, remotePhoneNumber: String) -> SignalCall {
|
||||
return SignalCall(localId: localId, signalingId: newCallSignalingId(), state: .dialing, remotePhoneNumber: remotePhoneNumber)
|
||||
return SignalCall(direction: .outgoing, localId: localId, signalingId: newCallSignalingId(), state: .dialing, remotePhoneNumber: remotePhoneNumber)
|
||||
}
|
||||
|
||||
class func incomingCall(localId: UUID, remotePhoneNumber: String, signalingId: UInt64) -> SignalCall {
|
||||
return SignalCall(localId: localId, signalingId: signalingId, state: .answering, remotePhoneNumber: remotePhoneNumber)
|
||||
return SignalCall(direction: .incoming, localId: localId, signalingId: signalingId, state: .answering, remotePhoneNumber: remotePhoneNumber)
|
||||
}
|
||||
|
||||
// -
|
||||
|
|
|
@ -528,6 +528,17 @@ class CallViewController: UIViewController, CallObserver, CallServiceObserver, R
|
|||
case .remoteBusy:
|
||||
return NSLocalizedString("END_CALL_RESPONDER_IS_BUSY", comment: "Call setup status label")
|
||||
case .localFailure:
|
||||
if let error = call.error {
|
||||
switch (error) {
|
||||
case .timeout(description: _):
|
||||
if self.call.direction == .outgoing {
|
||||
return NSLocalizedString("CALL_SCREEN_STATUS_NO_ANSWER", comment: "Call setup status label after outgoing call times out")
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return NSLocalizedString("END_CALL_UNCATEGORIZED_FAILURE", comment: "Call setup status label")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,9 @@
|
|||
/* Accessibilty label for placing call button */
|
||||
"CALL_LABEL" = "Call";
|
||||
|
||||
/* Call setup status label after outgoing call times out */
|
||||
"CALL_SCREEN_STATUS_NO_ANSWER" = "No Answer.";
|
||||
|
||||
/* embeds {{Call Status}} in call screen label. For ongoing calls, {{Call Status}} is a seconds timer like 01:23, otherwise {{Call Status}} is a short text like 'Ringing', 'Busy', or 'Failed Call' */
|
||||
"CALL_STATUS_FORMAT" = "Signal %@";
|
||||
|
||||
|
|
Loading…
Reference in New Issue