文件名称:mqttws31.js
文件大小:102KB
文件格式:JS
更新时间:2022-06-05 04:17:05
小程序mqtt
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); } }, })