kill the session after 30 second

merge-requests/147/head
Elham Rababah 6 years ago
parent 8db2f059ba
commit 1e27edf09f

@ -23,6 +23,8 @@ class ViewController: UIViewController {
var kToken:String = ""
var callBack: ICallProtocol?
var timer = Timer()
var seconds = 30
override func viewDidLoad() {
@ -208,6 +210,15 @@ class ViewController: UIViewController {
@IBOutlet weak var localVideoMutedIndicator: UIImageView!
@objc func updateTimer(){
seconds -= 1 //This will decrement(count down)the seconds.
print(seconds)
if seconds == 0 {
sessionDisconnect();
timer.invalidate()
}
}
}
@ -217,6 +228,12 @@ extension ViewController: OTSessionDelegate {
func sessionDidConnect(_ session: OTSession) {
print("The client connected to the OpenTok session.")
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: (#selector(ViewController.updateTimer)), userInfo: nil, repeats: true)
setupPublisher()
}
@ -305,6 +322,18 @@ extension ViewController: OTSessionDelegate {
subscriber = nil
}
func session(
_ session: OTSession?,
connectionCreated connection: OTConnection?
) {
// startTimer(callDuration, warningDuration)
if let connectionId = connection?.connectionId {
print("session connectionCreated (\(connectionId))")
}
timer.invalidate()
}
}
extension ViewController: OTPublisherDelegate {

Loading…
Cancel
Save