Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

block-messenger

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

block-messenger

Message exchange between pipeline blocks

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-50%
Maintainers
3
Weekly downloads
 
Created
Source

block-messenger

Simplifies message exchange between pipeline blocks.

Factory Pattern simplifies replacement of Client.

MQTT Client is Implemented based on NPM mqtt package

To Create a MQTT Client using the BlockMessenger Factory

options = {type = 'mqtt', ...}

To receive messages, listen to event 'message' (topic, message) To publish a message, messenger.publish(some_data, callback);

Usage example:

const BlockMessenger = require('../index').BlockMessenger;
const bm = new BlockMessenger();

const options = {
    type: "mqtt",
    host: '127.0.0.1',
    port: 1883,
    username: 'username,
    password: 'password,
    subscribe_topics: ['some/topic'],
    publish_topics: ['some/topic'],
    use_shared_topics: true,
    group_name: 'group'
};

const mqtt = bm.createMessenger(options);

mqtt.on('subscribed', (granted) => {
    console.log(granted);
});

mqtt.on('message', (topic, message) => {
    console.log(`new message in topic ${topic}:`, message.toString());
});

setInterval(() => {
    mqtt.publish('test data', (err) => {
        if (err) {
            console.error(err);
        }
        else {
            console.log('message sent');
        }
    });

}, 1000);

The MQTT Client also emits the following events:

  • connect

  • reconnect

  • close

  • offline

  • error

  • end

  • packetsend

  • packetreceive

  • message

  • subscribed

Run Tests

npm test npm run-script test-cov

TO DO:

  • Implement kafka-messenger.js (options.type = 'kafka')

FAQs

Package last updated on 25 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc