Skip to content

An implementation of the MQTT specification for connecting to any MQTT broker via MQTT.Cool server

License

Notifications You must be signed in to change notification settings

Lightstreamer/mqtt-lib-client-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MQTT.Cool Client SDK

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.

Quickstart

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)

npm Packages

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

Building

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.

Documentation

Support

For questions and support please use the Official Forum. The issue list of this page is exclusively for bug reports and feature requests.

License

Apache 2.0

About

An implementation of the MQTT specification for connecting to any MQTT broker via MQTT.Cool server

Resources

License

Stars

Watchers

Forks

Packages

No packages published