24 lines
709 B
JavaScript
24 lines
709 B
JavaScript
|
|
const options = {
|
|||
|
|
|
|||
|
|
clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8),
|
|||
|
|
username: "blwws",
|
|||
|
|
password: "E!9~3~H=M.&2STW",
|
|||
|
|
protocolVersion: 5
|
|||
|
|
};
|
|||
|
|
const client = mqtt.connect("wss://gua.blv-oa.com:8084/mqtt",options);
|
|||
|
|
|
|||
|
|
var hghg=$("#CurrentHotelID").val();
|
|||
|
|
client.on("connect", (error) =>
|
|||
|
|
{
|
|||
|
|
console.log("连接上了");
|
|||
|
|
client.subscribe("blw/upgrade_progress/report/"+hghg, (err) =>
|
|||
|
|
{
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
client.on("message", (topic, message) => {
|
|||
|
|
var data=message.toString();
|
|||
|
|
console.log(data);
|
|||
|
|
var jsondata=JSON.parse(data);
|
|||
|
|
mqtt_data(jsondata);
|
|||
|
|
});
|