1.1.4 • Published 4 months ago

mqtt-eventemitter v1.1.4

Weekly downloads
-
License
LGPL-2.1-only
Repository
github
Last release
4 months ago

mqtt-eventemitter (mqtt-ee)

npm version

MQTT with EventEmitter API and callback support

Goal

using MQTT with a EventEmitter based API. with out the need to handle subscribing. and the addition of callback support to other mqtt-eventemitter clients.

examples

see: examples dir

simple events
const mqtt_ee = require('mqtt-eventemitter');
const mqtt_server_url = 'mqtt://test.mosquitto.org';

// first client
mqtt_ee(mqtt_server_url).then(function init(node) {
    setInterval(function() {
        // MQTT topic foo/bar
        node.emit('foo::bar', 'arg1', new Date());
    }, 2000);
});
const mqtt_ee = require('mqtt-eventemitter');
const mqtt_server_url = 'mqtt://test.mosquitto.org';
// second client
mqtt_ee(mqtt_server_url).then(function init(node) {
    // MQTT topic foo/bar
    node.on('foo::bar', function(arg1, date){
        console.log('arg1', arg1);
        console.log('date', date);
    });
});
callback events
const mqtt_ee = require('mqtt-eventemitter');
const mqtt_server_url = 'mqtt://test.mosquitto.org';

// first client
mqtt_ee(mqtt_server_url).then(function init(node) {
    setInterval(function() {
        // MQTT topic foo/bar
        node.emit('foo::bar', 'arg1', function(date) {
            console.log('callback called with', date);
        });
    }, 2000);
});
const mqtt_ee = require('mqtt-eventemitter');
const mqtt_server_url = 'mqtt://test.mosquitto.org';
// second client
mqtt_ee(mqtt_server_url).then(function init(node) {
    // MQTT topic foo/bar
    node.on('foo::bar', function(arg1, cb){
        console.log('arg1', arg1);
        cb(new Date())
    });
});
1.1.4

4 months ago

1.1.1

7 months ago

1.1.0

8 months ago

1.1.3

7 months ago

1.1.2

7 months ago

1.0.2

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago