小弟在虚拟机中装了MAC系统
在Xcode中用pod安装了CocoaMQTT,使用代码如下:
let clientIdPid = "CocoaMqtt"
let mqtt = CocoaMQTT(clientId: clientIdPid, host: "114.55.145.185", port: 1883)
mqtt.username = "test"
mqtt.password = "public"
mqtt.keepAlive = 90
mqtt.willMessage = CocoaMQTTWill(topic: "topic", message: "hello")
mqtt.connect()
// dispatch_main()
每次执行上述代码,总会阻塞住,重启模拟器服务端才能收到发送的hello内容。
如果将dispatch_main()注释掉,服务端就不会收到hello。
求高手指点下,在线等。。。。。
自己顶顶,这个是从github上CocoaMQTT的Example,初次接触swift和mac,求指点。