Hi,
I'm trying to use Aphid and Mosquitto (a IOT communication protocol and software Framework).
However, when I try to connect I'm getting:
Error: Error code: -9989(0x-2705), Operation now in progress
Error type: Error
Error type displaystyle: struct
I'm only connecting once though.
Here's my code in different places. Can anyone help?
I'm guessing that I need to create a thread and schedule the connection in the thread. However, I don't know how to do this. Can someone help me with this> Below is my code:
import UIKit
import Foundation
import SystemConfiguration
import AphidFramework
/ No multiple inheritance so I made Aphid an NSObject */
class UberCameraClient: /NSObject, */ Aphid, StreamDelegate, MQTTDelegate {
var inputStream: InputStream!
var outputStream: OutputStream!
let maxReadLength = 4096
weak var uberCameraDelegate: UberCameraClientDelegate?
func setupNetworkCommunication(_ inputDelegate: UberCameraClientDelegate) {
do {
try self.connect();
print("Made it past connect");
} catch let unknownError {
/
print("Error: \(unknownError)")
print("Error type: \(type(of: unknownError))")
if let dispStyle = Mirror(reflecting: unknownError).displayStyle {
print("Error type displaystyle: \(dispStyle)")
}
}
.
.
.
/*********************************************************************** MQTT implementation */
init(clientId: String) {
super.init(clientId: "Test", cleanSess: true, username: nil, password: nil,
host: "192.168.1.73", port: 1883);
super.delegate = self;
}
func didConnect() {
print("I connected!")
}
func didLoseConnection() {
print("connection lost")
}
func didCompleteDelivery(token: String) {
print(token)
}
func didReceiveMessage(topic: String, message: String) {
print(topic, message)
}
/*
This method is called when the connection to the server is lost.
throws: cause of the reason behind the loss of connection.
*/
func didLoseConnection(error: Error?) {
print("lost Connection");
}
}