|
@@ -151,10 +151,12 @@ App({
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // topic
|
|
|
|
+ // /AIrSMArT_7cdfa1fd3af0/status/onoffline
|
|
|
|
+ // /AIrSMArT_7cdfa1fd3af0/user/pub_response
|
|
// 订阅主题
|
|
// 订阅主题
|
|
subscribe: function (topic, callback) {
|
|
subscribe: function (topic, callback) {
|
|
var that = this;
|
|
var that = this;
|
|
- console.log("gasdfqwerqweqr===00==" + topic);
|
|
|
|
if (that.globalData.client && that.globalData.client.connected) {
|
|
if (that.globalData.client && that.globalData.client.connected) {
|
|
//订阅主题
|
|
//订阅主题
|
|
that.globalData.client.subscribe(topic, function (err, granted) {
|
|
that.globalData.client.subscribe(topic, function (err, granted) {
|
|
@@ -197,20 +199,28 @@ App({
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- console.log("gasdfqwerqweqr===11==" + JSON.stringify(option));
|
|
|
|
- console.log("gasdfqwerqweqr===22==" + option.type);
|
|
|
|
- console.log("gasdfqwerqweqr===33==" + option.DstDeviceName);
|
|
|
|
- console.log("gasdfqwerqweqr===44==" + `ALY_${that.globalData.userInfo.userId}`);
|
|
|
|
|
|
+ // {"type":"get_dev_info","DstDeviceName":"AIrSMArT_7cdfa1fd3af0"}
|
|
|
|
+ // get_dev_info
|
|
|
|
+ var type = option.type;
|
|
|
|
+ // AIrSMArT_7cdfa1fd3af0
|
|
|
|
+ var DstDeviceName = option.DstDeviceName;
|
|
|
|
+ // ALY_933625
|
|
|
|
+ var SrcDeviceName = `ALY_${that.globalData.userInfo.userId}`;
|
|
if (that.globalData.client && that.globalData.client.connected) {
|
|
if (that.globalData.client && that.globalData.client.connected) {
|
|
const data = {
|
|
const data = {
|
|
- "type": option.type,
|
|
|
|
- "DstDeviceName": option.DstDeviceName,
|
|
|
|
- "SrcDeviceName": `ALY_${that.globalData.userInfo.userId}`,
|
|
|
|
|
|
+ "type": type,
|
|
|
|
+ "DstDeviceName": DstDeviceName,
|
|
|
|
+ "SrcDeviceName": SrcDeviceName,
|
|
};
|
|
};
|
|
if (option.other) {
|
|
if (option.other) {
|
|
data.other = option.other;
|
|
data.other = option.other;
|
|
};
|
|
};
|
|
- that.globalData.client.publish(`/${option.DstDeviceName}/user/sub_control`, `${JSON.stringify(data)}`, (err) => {
|
|
|
|
|
|
+
|
|
|
|
+ // /AIrSMArT_7cdfa1fd3af0/user/sub_control
|
|
|
|
+ var publish = `/${DstDeviceName}/user/sub_control`;
|
|
|
|
+ // {"type":"get_dev_info","DstDeviceName":"AIrSMArT_7cdfa1fd3af0","SrcDeviceName":"ALY_933625"}
|
|
|
|
+ var dataString = `${JSON.stringify(data)}`;
|
|
|
|
+ that.globalData.client.publish(publish, dataString, (err) => {
|
|
if (err) {
|
|
if (err) {
|
|
console.log("发布消息失败");
|
|
console.log("发布消息失败");
|
|
}
|
|
}
|