De Les Fabriques du Ponant
|
|
| (9 révisions intermédiaires par le même utilisateur non affichées) |
| Ligne 1 : |
Ligne 1 : |
| − | | + | avec : https://mqttx.app/ |
| − | <html>
| |
| − | <!DOCTYPE html>
| |
| − | <html>
| |
| − | <head>
| |
| − | <meta charset="utf-8" />
| |
| − | <title>Example</title>
| |
| − | <script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
| |
| − | </head>
| |
| − | <body>
| |
| − | <button id="button">Envoie un pokou</button>
| |
| − | | |
| − | <script>
| |
| − | const client = mqtt.connect('wss://poclpokou:pokou@debrouillards.ddns.net:1883', {
| |
| − | clientId: 'WikiTestDemo'
| |
| − | });
| |
| − | | |
| − | client.on('connect', function() {
| |
| − | console.log('connected!');
| |
| − | client.subscribe('Poke');
| |
| − | });
| |
| − | | |
| − | client.on('message', function(topic, message) {
| |
| − | console.log(topic + ': ' + message.toString());
| |
| − | });
| |
| − | | |
| − | document.querySelector('button').addEventListener('click', function() {
| |
| − | client.publish('Poke', 'pokou');
| |
| − | });
| |
| − | </script>
| |
| − | </body>
| |
| − | </html>
| |
Version actuelle datée du 27 novembre 2024 à 19:01