A MQTT webcomponent, allowing to have several subscribers and publishers.
The component connect to the MQTT server through a websocket.
The component is based on the Paho javascript client library.
The component has no GUI.
The component is provided in ES6
<link rel="import" href="bower_components/tsante-mqtt.html">
or for older browser in ES5
<link rel="import" href="bower_components/tsante-mqtt.es5.html">
Nota : the demo doesn't work on webcomponents.org, due to permission access to the localstorage, to see a demo please consult the demo link below.
<tsante-mqtt host="ws://test.mosquitto.org:8080/" >
<tsante-mqtt-subscriber topic="terminal/hello"></tsante-mqtt-subscriber>
<tsante-mqtt-publisher id="publisher"
topic="terminal/hello"
payload="polymer"></tsante-mqtt-publisher>
</tsante-mqtt>
The component is licensed under the ISC License
Demo and doc are available on https://telecomsante.github.io/tsante-mqtt/
starting 1.4.0, it's possible to embed more deeper susbscribers and publishers
<tsante-mqtt host="ws://test.mosquitto.org:8080/" >
<div>
<tsante-mqtt-subscriber topic="terminal/hello"></tsante-mqtt-subscriber>
<tsante-mqtt-publisher id="publisher"
topic="terminal/hello"
payload="polymer"></tsante-mqtt-publisher>
</div>
</tsante-mqtt>
BREAKING CHANGE :
tsante-mqtt-received
events are fired bytsante-mqtt-subscriber
elements rather than bytsante-mqtt
however as the events bubble it's always possible to get the events from the
tsante-mqtt
ancestor. In this case some events can appear to be emitted several time, but look at the evt.target it must be different.
prerequisites : You will need to have docker and docker-compose installed
To run the test suites, you must start a local MQTT server. This is automatically done when running :
npm test
npm run mosquitto:start : starts a MQTT server into a docker container
npm run mosquitto:stop : stops the MQTT server
npm test : starts the MQTT server and runs the test suites on all installed browsers.
npm run build-es5 : builds es5 compatible components
The development of this component follows the git flow recommandations, so when you fork this repository and want to do a PR (push request), do it on the "develop" branch.