Comments (16)
As a workaround (or is it the proper way?) I did this in my component mounted() method:
this.$mqtt.subscribe('param/param/param/#')
this.$mqtt.on('message', (topic, message) => {
if (topic.match('param/param/param/')) {
console.log('matched!')
}
})
Hope it helps :)
from vue-mqtt.
I have the same issue as above.
from vue-mqtt.
Thank you so much for this. Even though this is potentially a workaround, it does seem to add some additional flexibility. Thanks again!
from vue-mqtt.
Hi.
I use so:
created () {
this.$mqtt.subscribe('WebExtension/v1/' + this.userProfile.email + '/#')
}
mqtt: {
Payment_Rsp (response) {
...
},
BuyResult_Ind (response) {
...
}
}
Full topic is "WebExtension/v1/[email protected]/Payment_Rsp" and "WebExtension/v1/[email protected]/BuyResult_Ind"
from vue-mqtt.
Hi,
Maybe i'm mis-using / misunderstanding mqtt topics.
I'm using topic === 'provisioning/key/confirm/123456'
where '123456' is actually a variable.
that's why i can't use :
mqtt: {
[SOME_VARIABLE_NAME] (response) {
...
},
...
The variable name is not known ahead of time.
I'm building a handshaking / provisioning system so the '123456' is a keycode the user enters on a remote keypad and has to be passed around for a little while.
from vue-mqtt.
I can change to work like this:
created () {
this.$mqtt.subscribe('provisioning/key/confirm/#')
}
mqtt: {
allTopics (response) {
// for all topic,
// for example 'provisioning/key/confirm/123' | 'provisioning/key/confirm/456'
}
}
from vue-mqtt.
hmm, i have other subs on this component too, they would also match, no?
from vue-mqtt.
All topics that match ''provisioning/key/confirm/#"
from vue-mqtt.
hmm, what if this ... ?
created () {
this.$mqtt.subscribe('provisioning/key/confirm/#')
this.$mqtt.subscribe('provisioning/something/something/#')
}
mqtt: {
allTopics (response) {...}
}
from vue-mqtt.
oh... I understood the problem. I'll think about it and write.
from vue-mqtt.
Cheers :)
from vue-mqtt.
Done. See example
https://github.com/nik-zp/Vue-Mqtt-Example
from vue-mqtt.
Thank you very much for this. I tested it and everything seems to be working fine. I am not sure if this will be a separate request or maybe just something to figure out in the future, but one advantage that this,$mqtt.on still has is that its possible to see the original topic.
An example to highlight this is
Publish to : 'results/1/led' and 'results/2/led'
Subscribe to : 'results/+/led/'
MQTT function only has a parameter of val, so I am currently unable to distinguish between 1 & 2.
I understand this was not in the original request but just thought I would mention it. Thanks again for the quick work!
from vue-mqtt.
@cuanjooste, hi.
see example for [email protected]:
mqtt: {
'results/+/led' (data, topic) {
if (topic.split('/')[1] === '1234') {
// ...
}
}
}
from vue-mqtt.
@nik-zp That is perfect, thank you so much!!!!
from vue-mqtt.
Thanks also ! :)
I had to move off this project for now but will be sure to use this when i get back to it.
from vue-mqtt.
Related Issues (19)
- u is not a constructor - usage in nuxt HOT 1
- How to connect AWS IOT by vue-mqtt
- how to detect failed: Error in connection establishment HOT 2
- mqtt proxy is created for all child components
- MQTT.js ok but vue-mqtt doesn't connect HOT 2
- vue-mqtt in combination with the vuex HOT 1
- Please set a license HOT 1
- Object literal may only specify known properties
- Vue3 support HOT 5
- Mqtt Authentification via Options HOT 4
- got ERR_CERT_DATE_INVALID : Can I bypass SSL certificate? HOT 1
- how to have the connection status reactive HOT 1
- close connection HOT 2
- Can not call reconnect()
- can't match some topic
- can't match topic with '/' start
- Update mqtt version
- Browser starts lagging when I connect to my mosquitto broker HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-mqtt.