CocoaMQTT 是用于 iOS 和 OSX 的 MQTT 客户端,用 Swift 编写。
目前支持 MQTT 3.1 (不是 MQTT 3.1.1)
使用:
let mqtt = CocoaMQTT(clientId: "CocoaMQTT-ClientId") mqtt.username = "test" mqtt.password = "public" mqtt.willMessage = CocoaMQTTWill(topic: "/will", message: "dieout") mqtt.keepAlive = 5 mqtt.delegate = CocoaMQTTCli() mqtt.connect()