Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
- <script>
- const client = mqtt.connect("ws://localhost:1884") // you add a ws:// url here
- client.subscribe("mqtt/demo")
- client.on("message", function (topic, payload) {
- console.log("on.message: ", topic, payload)
- client.end()
- })
- client.publish("mqtt/demo", "hello world!")
- </script>
- </head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement