1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React from 'react';
import { Button } from 'antd';
import PandaMqttView from '../index';
class MqttDemo extends React.Component {
constructor(props) {
super(props);
this.state = {
flag: true,
};
this.mqttView = new PandaMqttView({
mqttIP: 'emqttd10.panda-water.cn:443',
mqttPath: '/mqtt',
mqttSsl: true,
siteCode: 'site_shsys656',
devices: ['QSJZ00000001', 'SHBF00000001', 'SHJZ00000001'],
callback: () => {
this.setState({ flag: false });
},
controlback: () => {},
});
}
saveMqtt() {
this.mqttView.saveWaterMqtt();
}
destroyMqtt() {
this.mqttView.disSaveWaconnect();
this.setState({ flag: true });
}
render() {
return (
<>
<Button
type="primary"
key={'Button1'}
disabled={!this.state.flag}
onClick={this.saveMqtt.bind(this)}
>
Mqtt连接
</Button>
<Button
type="primary"
key={'Button2'}
disabled={this.state.flag}
onClick={this.destroyMqtt.bind(this)}
style={{ marginLeft: '10px' }}
>
Mqtt销毁
</Button>
</>
);
}
}
export default MqttDemo;