Open sw-tt-rushabhpatel opened 4 years ago
Creates an empty array of CocoaMQTT called instanceArray. You can add elements to this array and create multiple instance.
let hostArray:[String] = ["host1", "host2", "host3"]
var instanceArray = [CocoaMQTT]()
for host in hostArray {
mqtt = CocoaMQTT(clientID: host + String(ProcessInfo().processIdentifier), host: host, port: 1883)
//...
instanceArray.append(mqtt!)
}
print("clientID = \(instanceArray[2].clientID)")
How can we connect multiple devices using mqtt ?