From ada6da9506cd4da238fbf7cd784f18d2bee06774 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 13 Jan 2017 17:25:28 -0500 Subject: [PATCH] Fix merge. The changes to SignalCall must have been lost as I tried to apply swift lint to them. // FREEBIE --- Signal/src/call/SignalCall.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Signal/src/call/SignalCall.swift b/Signal/src/call/SignalCall.swift index 0d975fd5d..18343b78f 100644 --- a/Signal/src/call/SignalCall.swift +++ b/Signal/src/call/SignalCall.swift @@ -41,6 +41,16 @@ protocol CallDelegate: class { var state: CallState { didSet { Logger.debug("\(TAG) state changed: \(oldValue) -> \(state)") + + // Update connectedDate + if state == .connected { + if connectedDate == nil { + connectedDate = NSDate() + } + } else { + connectedDate = nil + } + delegate?.stateDidChange(call: self, state: state) } } @@ -50,6 +60,7 @@ protocol CallDelegate: class { delegate?.muteDidChange(call: self, isMuted: isMuted) } } + var connectedDate: NSDate? var error: CallError? @@ -76,6 +87,11 @@ protocol CallDelegate: class { static func newCallSignalingId() -> UInt64 { return UInt64.ows_random() } + + // This method should only be called when the call state is "connected". + func connectionDuration() -> TimeInterval { + return -connectedDate!.timeIntervalSinceNow + } } fileprivate extension UInt64 {