Skip to content

Pure JavaScript MQTT client library for Cordova. Wrapper around Paho.js

Notifications You must be signed in to change notification settings

tonolucro/cordova-plugin-mqtt-pahojs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pure JavaScript MQTT client library. Wrapper for paho.js by BeeToo

Installation

For Cordova CLI users:

cordova plugin add cordova-plugin-mqtt-pahojs

Usage example

new window.plugins.mqtt({
            uri: MQTT_URI,
            keepAliveInterval: 120,
            clientId: MQTT_CLIENT_ID,
            reportConnectionStatus: false,
            reconnectDelay: [1000, 5000, 10000, -1]
        });
        btc.connect();

var connection = new window.plugins.mqtt({
    uri: 'ws://192.168.2.107:8080',
    keepAliveInterval: 120,
    clientId: 'BeeToo_MQTT',
    reportConnectionStatus: true,
    reconnectDelay: [1000, 5000, 10000, -1] //three tries to reconnect will take place. If -1 met, then reconnect process will stop.
});
connection.on('connected', function () {
    connection.subscribe('/russia/moscow/beetoo_status', {qos: 2});
    connection.publish('/russia/moscow/beetoo', 'hi, gyus!', {qos: 1, retained: true});
    connection.on('/russia/moscow/beetoo_status', function (value) {
        console.log('Yay! Value is: ' + value);
    });
});

connection.connect();

The MIT License (MIT)

About

Pure JavaScript MQTT client library for Cordova. Wrapper around Paho.js

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%