Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Push button, send message</title>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.js" type="text/javascript"></script>
- </head>
- <body>
- <button onclick="sendMessage();">Push Me</button>
- <script type="text/javascript">
- var clientID = "ID-" + Math.round(Math.random() * 1000);
- var client = new Paho.MQTT.Client("192.168.0.23", "1883", clientID);
- client.connect({onSuccess:onConnect});
- function onConnect() {
- console.log("connected");
- }
- function sendMessage() {
- console.log("sending");
- var message = new Paho.MQTT.Message("qplaypause");
- message.destinationName = "cycy42/skyq";
- client.send(message);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement