Please select Into the mobile phone version | Continue to access the computer ver.
Close
You need to log in before you can reply       Login | Register now

[Device] How to fix this code (swift) ?

Author: aismaae.k 2017-8-9 18:06
0 72
Last edited by aismaae.k In 2017-8-10 10:02 Editor

import UIKit
import SocketIO
import DJISDK

class SocketIOManager: NSObject {
    static let sharedInstance = SocketIOManager()
    var socket = SocketIOClient(socketURL: URL(string: "http://192.168.1.48:3000")!, config: [.log(false), .forcePolling(true)])

    struct GimbalState {
        var pitchDegrees: Float
     }

    var gimbalPitchDegrees: Float = 0.0

    override init() {
        super.init(gimbalFromDjiAircraft: DJIGimbal) {
            djiGimbal = gimbalFromDjiAircraft
       }

        socket.on("UP") { dataArray, ack in
            print(dataArray)
            NSLog("message received : %@", dataArray)
            self.gimbalPitchDegrees = 5.0
        }

        socket.on("DOWN") { dataArray, ack in
            print(dataArray)
            NSLog("message received : %@", dataArray)
            self.gimbalPitchDegrees = -5.0
        }

        socket.on("status update") { dataArray, ack in
            NotificationCenter.default
                .post(name: Notification.Name(rawValue: "callStatusUpdateNotification"), object: dataArray[0] as? [String: AnyObject])
        }

    }

Reply
Replies
You need to log in before you can reply Login | Register now

Quick Reply Back to top Back to list
Quick Reply Back to top Back to list