@createview/mqtt-manager
Npm package to configure mqtt in easy way without need for duplicated code
Last updated a year ago by arn-the-long-beard .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @createview/mqtt-manager 
SYNC missed versions from official npm registry.

mqtt-manager

Npm package to configure mqtt in easy way without need for duplication code

JavaScript Style Guide License: MIT Build Status stability-experimental NSP Status

Stability

Expect the unexpected. Please provide feedback on api and your use-case

Installation

`npm install @createview/mqtt-manager

Usage

// lets make a json config file like this :

{
  "connection": "mqtt://127.0.0.1'",
  "publication": {
    "Greeting B" :  "Greeting B",
    "Bye B" :  "Bye B"
  },
  "subscription":{
    "Greeting A" : "Greeting A",
    "Bye A" :   "Bye A"
  }
}

Here is a way of using it. You can also try npm run testA and npm run testB is this order

'use strict'
const MqttManager = require('./index.js')
const mqttconfig = require('./configA')
// define the functions to trig on messages
function displayGreeting (msg, data, mqttService) {
  console.log(data)
  // can send other message
  mqttService.publish(mqttconfig.publication['Greeting B'], 'Hello B')
}

function displayBye (msg, data, mqttService) {
  console.log(data)
  // can send other message
  mqttService.publish(mqttconfig.publication['Bye B'], 'bye byeB ')
}

let actions = [

]
// add actions on subscriptions
actions.push({topic: mqttconfig.subscription['Bye A'], func: displayBye})
actions.push({topic: mqttconfig.subscription['Greeting A'], func: displayGreeting})

// create a new Mqttmanager
let mqttService = new MqttManager()

// Sett he config
mqttService.setup(mqttconfig, actions)

Tests

npm test

Comments

PS : the packages was previously named @createview/mqtt-service I am very sorry for the desagrement caused by the remove of this package from Npm. I prefered to delete it after 24 h to put a good name on it :)

The package needs improvement

Contributing

arn-the-long-beard

Current Tags

  • 1.1.0                                ...           latest (a year ago)

4 Versions

  • 1.1.0                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.1.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 15
Dependencies (5)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |