Va chercher l'url du broker en variable de configuration

This commit is contained in:
Laurent 2024-02-17 19:14:14 +00:00
parent 7102aab6fa
commit cf7d7e500f
3 changed files with 10 additions and 1 deletions

3
.gitignore vendored
View File

@ -28,3 +28,6 @@ coverage
*.sw?
*.tsbuildinfo
# Local configuration file
/src/config.js

4
src/config.js.example Normal file
View File

@ -0,0 +1,4 @@
// config.js
export default {
mqttBrokerUrl: 'ws://localhost:9001'
};

View File

@ -1,7 +1,9 @@
import mqtt from 'mqtt';
import config from '@/config.js';
const mqttBrokerUrl = config.mqttBrokerUrl;
// Créer une instance de client MQTT
const client = mqtt.connect('ws://localhost:9001');
const client = mqtt.connect(mqttBrokerUrl);
// Fonction pour publier un message sur un topic MQTT
export function publishMessage(topic, message) {