MQTT.Cool is a gateway designed for boosting existing MQTT brokers by extending their native functionalities with new out-of-the-box features. It provides architecture, performance and security extensions to any third-party MQTT broker.
The MQTT.Cool Client SDK is a JavaScript library for the development of MQTT.Cool clients running inside a web browser or a Node.js container.
The library enables any javascript program to act as an MQTT client; that is, ready to send and receive real-time MQTT messages to/from any MQTT broker connected to the MQTT.Cool server.
Open a session against the MQTT.Cool server, create an MQTT client and connect to the MQTT broker:
mqttcool.openSession('http://my.MQTT.Cool.server:8080', 'my_user', 'my_password', {
onConnectionSuccess: function(mqttCoolSession) {
var client = mqttCoolSession.createClient('my_mqtt_broker', 'my_client_id');
client.connect({
onSuccess: function() {
console.log("Connected!");
}
});
...
}
});
Request a Subscription:
client.subscribe("my/cool/topic");
Listen for messages:
client.onMessageArrived = function(message) {
console.log("onMessageArrived:" + message.payloadString);
}
Publish a Message to the server:
message = new mqttcool.Message("My Message!");
message.destinationName = "my/cool/topic";
client.send(message)
The library is available as npm package, so you can download and install it through:
npm install mqtt.cool-web-client
or
npm install mqtt.cool-node-client
To build the library, enter the directory tools
and run the command node build_web.js
or the command node build_node.js
. The first time you should also enter the root directory of the project and run the command npm install
in order to install the dependencies required by the build scripts. The scripts require Node.js version 14 or greater.
The artifacts generated are saved in the directories tools/dist-web
and tools/dist-node
.
For questions and support please use the Official Forum. The issue list of this page is exclusively for bug reports and feature requests.