mirror of
https://codeberg.org/Far-Open-Auth.en-soln/mqttcsimpl/
synced 2024-08-14 23:53:51 +00:00
.
This commit is contained in:
parent
1f09275d2e
commit
01236ad8fb
3 changed files with 70 additions and 0 deletions
32
index.html
Normal file
32
index.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Testing</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="https://unpkg.com/mqtt@4.3.7/dist/mqtt.min.js"></script> <!-- Load client mqtt via CDN. -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script type="module">
|
||||
const mqtt = require('mqtt')
|
||||
const client = mqtt.connect('mqtt://mosquitto.domain.tld') // testoo
|
||||
|
||||
client.on('connect', function () {
|
||||
client.subscribe('presence', function (err) {
|
||||
if (!err) {
|
||||
client.publish('presence', 'Hello mqtt')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
client.on('message', function (topic, message) {
|
||||
// message is Buffer
|
||||
console.log(message.toString())
|
||||
client.end()
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue