node-adm | Node.js Wrapper for Amazon Device Messaging | Runtime Evironment library
kandi X-RAY | node-adm Summary
kandi X-RAY | node-adm Summary
Node.js Wrapper for Amazon Device Messaging
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Creates a new Sender .
node-adm Key Features
node-adm Examples and Code Snippets
Community Discussions
Trending Discussions on node-adm
QUESTION
old Rails and php programmer that is new to js, tyring something and feel I am missing something pretty basic. I have a node server running a small webapp, express, ejs, jquery as well as alpinejs. (very exp with jquery, but learning alpinejs). I have a mqtt server running and can manipulate a couple of topics via my phone, and I can even see them in the node console (code below)
what I fail to understand is how to get, or maybe "bind" the subscription to a variable that I can "pass" into the express app so I can just show the mqtt message in the html. Im currently just trying to set things like fridgeFan = true
or somehthing. My idea, I think, is to have mqtt update the alpinejs variable, hence updating the page, then viceversa...
Can someone point me in the general good direction of what im attemtping?
...ANSWER
Answered 2021-Apr-04 at 11:52You can't move your on message handler into the EJS files as they are only "executed" at the point you call render()
You can declare a global variable in the ExpressJS app and update fields with in it from the on('message',...)
callback, you then pass this variable into the call to render()
but this would mean that the page would only show the value at the time the page was loaded.
If you want live updates in the page as messages are published then you have one real option. That is to use a broker that supports MQTT over Websockets (nearly all modern brokers support this). With this you can load an MQTT client (either the Paho JavaScript client or you can use the MQTT.js client) into the page and subscribe to the topics you are interested in directly from the page. This way new messages are delivered directly to the page and you can then use what ever JavaScript framework you want to update the page.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-adm
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page