Va chercher l'url du broker en variable de configuration
This commit is contained in:
parent
7102aab6fa
commit
cf7d7e500f
3
.gitignore
vendored
3
.gitignore
vendored
@ -28,3 +28,6 @@ coverage
|
||||
*.sw?
|
||||
|
||||
*.tsbuildinfo
|
||||
|
||||
# Local configuration file
|
||||
/src/config.js
|
4
src/config.js.example
Normal file
4
src/config.js.example
Normal file
@ -0,0 +1,4 @@
|
||||
// config.js
|
||||
export default {
|
||||
mqttBrokerUrl: 'ws://localhost:9001'
|
||||
};
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user