forked from fustyles/webduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webduinomqtt.html
20 lines (20 loc) · 1 KB
/
webduinomqtt.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script src="https://blocklypro.webduino.io/components/jquery/dist/jquery.min.js"></script>
<script src="https://blocklypro.webduino.io/dist/lib/webduino-all-0.4.20.min.js"></script>
<script src="https://blocklypro.webduino.io/dist/webduino-blockly.min.js"></script>
<script src="https://blocklypro.webduino.io/dist/lib/firebase.min.js"></script>
<script src="https://blocklypro.webduino.io/dist/lib/runtime.min.js"></script>
<script src="https://blocklypro.webduino.io/node_modules/webduino-module-mqtt/mqttClient.min.js"></script>
<script id="jsbin-javascript">
(async function () {
var topic = "my/helloworld";
var webduinoMQTTClient = new webduino.module.mqttClient();
await webduinoMQTTClient.connect({ server: 'wss://mqtt1.webduino.io/mqtt' });
await webduinoMQTTClient.subscribe(topic);
var strUrl=location.search;
if (strUrl.indexOf("?")!=-1) {
webduinoMQTTClient.send({topic: topic,message: strUrl.split("?")[1]});
document.write(strUrl.split("?")[1]);
window.close();
}
}());
</script>