123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //
- // Callback.swift
- // Runner
- //
- // Created by Yayan Dwi on 15/04/20.
- // Copyright © 2020 The Chromium Authors. All rights reserved.
- //
- import Foundation
- import nuSDKService
- class Callback : CallBack {
- var sID: String = "Callback"
-
- func connectionStateChanged(sUserID: String!, sDeviceID: String!, bConState: Bool!, nConType: Int!, nConSubType: Int!, nCLMConStat: UInt8!) {
- //print(sUserID, "/", sDeviceID, "/", bConState, "/", nConType, "/", nConSubType, "/", nCLMConStat)
- if let dispatch = DigiX.dispatch, bConState {
- dispatch.leave()
- }
- if let delegate = DigiX.shared.connectionDelegate {
- delegate.connectionStateChanged(userId: sUserID, deviceId: sDeviceID, state: bConState)
- }
- OutgoingThread.default.set(wait: nCLMConStat == 0)
- }
-
- func gpsStateChanged(nState: Int!) {
-
- }
-
- func sleepStateChanged(bState: Bool!) {
-
- }
-
- func callStateChanged(nState: Int!, sMessage: String!) -> Int {
- //print(nState,"/",sMessage)
- if nState == DigiX.AUDIO_CALL_INCOMING || nState == DigiX.VIDEO_CALL_INCOMING {
- if let delegate = DigiX.shared.callDelegate {
- if !DigiX.showLibraryNotification {
- delegate.onStatusCall(state: nState, message: sMessage)
- } else {
- delegate.onIncomingCall(state: nState, message: sMessage)
- }
- }
- } else {
- // if nState == 28 {
- // let pin = sMessage.split(separator: ",")[0]
- // if let call = Palio.shared.callManager.call(with: String(pin)), !call.hasVideo, !call.hasEnded {
- // call.reconnectingCall()
- // return 1
- // }
- // }
- if let delegate = DigiX.shared.callDelegate {
- delegate.onStatusCall(state: nState, message: sMessage)
- }
- }
-
- return 1
- }
-
- func bcastStateChanged(nState: Int!, sMessage: String!) -> Int {
- //print(("LS CALLBACK ",nState,"/",sMessage)
- if let delegate = DigiX.shared.streamingDelagate {
- delegate.onStartLS(state: nState, message: sMessage)
- }
- if let delegate = DigiX.shared.streamingDelagate {
- delegate.onJoinLS(state: nState, message: sMessage)
- }
- if let delegate = DigiX.shared.seminarDelegate {
- delegate.onStartSeminar(state: nState, message: sMessage)
- }
- if let delegate = DigiX.shared.seminarDelegate {
- delegate.onJoinSeminar(state: nState, message: sMessage)
- }
- return 1
- }
-
- func sshareStateChanged(nState: Int!, sMessage: String!) -> Int {
- //print(("Screen sharing state: ",nState,"/",sMessage)
- switch nState {
- case 0:
- if (sMessage.starts(with: "Initiating")){
- if let delegate = DigiX.shared.screenSharingDelegate {
- delegate.onStartScreenSharing(state: nState, message: sMessage)
- }
- }
- case 12:
- if let delegate = DigiX.shared.screenSharingDelegate {
- delegate.onStartScreenSharing(state: nState, message: sMessage)
- }
- case 22:
- if let delegate = DigiX.shared.screenSharingDelegate {
- delegate.onJoinScreenSharing(state: nState, message: sMessage)
- }
- case 88:
- if let delegate = DigiX.shared.screenSharingDelegate {
- delegate.onStartScreenSharing(state: nState, message: sMessage)
- }
- if let delegate = DigiX.shared.screenSharingDelegate {
- delegate.onJoinScreenSharing(state: nState, message: sMessage)
- }
- default:
- break
- }
- return 1
- }
-
- func incomingData(sPacketID: String!, oData: AnyObject!) throws {
- DigiX.incomingData(packetId: sPacketID!, data: oData!)
- }
-
- func lateResponse(sPacketID: String!, sResponse: String!) throws {
-
- }
-
- func asycnACKReceived(sPacketID: String!) throws {
- //print(("asycnACKReceived: \(sPacketID)")
- DispatchQueue.global().async {
- Database.shared.database?.inTransaction({ (fmdb, rollback) in
- OutgoingThread.default.delOutgoing(fmdb: fmdb, packageId: sPacketID)
- })
- }
- }
-
- func locationUpdated(lTime: Int64!, sLocationInfo: String!) {
-
- }
-
- func resetDB() {
-
- }
-
- }
|