|
|
|
|
@ -8,6 +8,7 @@
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
import OpenTok
|
|
|
|
|
import Alamofire
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ViewController: UIViewController {
|
|
|
|
|
@ -25,6 +26,7 @@ class ViewController: UIViewController {
|
|
|
|
|
var callBack: ICallProtocol?
|
|
|
|
|
var timer = Timer()
|
|
|
|
|
var seconds = 30
|
|
|
|
|
var isUserConnect : Bool = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
|
@ -37,6 +39,38 @@ class ViewController: UIViewController {
|
|
|
|
|
setupSession()
|
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func callApi() {
|
|
|
|
|
let URL_USER_REGISTER = "https://uat.hmgwebservices.com/LiveCareApi/DoctorApp/GetSessionStatus"
|
|
|
|
|
let headers: HTTPHeaders = [
|
|
|
|
|
"Content-Type":"application/json",
|
|
|
|
|
"Accept":"application/json",
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
let parameters = [
|
|
|
|
|
"VC_ID": 3245,
|
|
|
|
|
"TokenID": "hfkjshdf347r8743",
|
|
|
|
|
"generalid": "Cs2020@2016$2958",
|
|
|
|
|
"DoctorId" : 1485 ,
|
|
|
|
|
] as [String : Any]
|
|
|
|
|
Alamofire.request(URL_USER_REGISTER, method: .post,parameters: parameters, encoding: JSONEncoding.default, headers: headers).responseJSON{
|
|
|
|
|
response in
|
|
|
|
|
if self.isUserConnect {
|
|
|
|
|
} else {
|
|
|
|
|
if let result = response.result.value {
|
|
|
|
|
let jsonData = result as! NSDictionary
|
|
|
|
|
self.callBack?.sessionNotResponded(res: ["sessionStatus":jsonData, "callResponse":"CallNotRespond"])
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
self.sessionDisconnect();
|
|
|
|
|
self.timer.invalidate()
|
|
|
|
|
}
|
|
|
|
|
//getting json value from the server
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func setupButtons() {
|
|
|
|
|
perform(#selector(hideControlButtons), with: nil, afterDelay: 3)
|
|
|
|
|
@ -115,7 +149,7 @@ class ViewController: UIViewController {
|
|
|
|
|
if (session != nil) {
|
|
|
|
|
print("disconnecting....")
|
|
|
|
|
session!.disconnect(nil)
|
|
|
|
|
callBack?.sessionDone()
|
|
|
|
|
callBack?.sessionDone(res:["callResponse":"CallEnd"])
|
|
|
|
|
dismiss(animated: true)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
@ -214,10 +248,10 @@ class ViewController: UIViewController {
|
|
|
|
|
seconds -= 1 //This will decrement(count down)the seconds.
|
|
|
|
|
print(seconds)
|
|
|
|
|
if seconds == 0 {
|
|
|
|
|
sessionDisconnect();
|
|
|
|
|
timer.invalidate()
|
|
|
|
|
callApi()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@ -330,7 +364,7 @@ extension ViewController: OTSessionDelegate {
|
|
|
|
|
if let connectionId = connection?.connectionId {
|
|
|
|
|
print("session connectionCreated (\(connectionId))")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isUserConnect = true
|
|
|
|
|
timer.invalidate()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|