mqttws31.js 用于小程序 mqtt 服务,端口的话必须为443,
app.globalData.client.connect({
userName: app.globalData.userInfo.nickName,
password: '',
useSSL: false,
cleanSession: false,
keepAliveInterval: 60,
onSuccess: function () {
app.globalData.client.subscribe(that.data.channel, {
qos: 0
});
app.globalData.client.publish(that.data.channel, JSON.stringify({ cmd: 'add', uid: app.globalData.userInfo.nickName, msg: '' }), 0, false);
}
});
}else {
app.globalData.client.publish(that.data.channel, JSON.stringify({ cmd: 'onlineSet', uid: [app.globalData.userInfo.nickName], msg: '' }), 0, false);
}
},
})
1