<commit_before># mqtt-router [![Build Status](https://travis-ci.org/wolfeidau/mqtt-router.png?branch=master)](https://travis-ci.org/wolfeidau/mqtt-router)

This module a router for use with MQTT subscriptions.

[![NPM](https://nodei.co/npm/mqtt-router.png)](https://nodei.co/npm/mqtt-router/)
[![NPM](https://nodei.co/npm-dl/mqtt-router.png)](https://nodei.co/npm/mqtt-router/)

## Installation

```
npm install mqtt-router
```

# usage

Exposes an array of functions which retrieves and returns data.

```javascript
var mqtt = require('mqtt');
var mqttrouter = require('mqtt-router');
var debug = require('debug')('mqtt:consumer');

var client = mqtt.createClient();

var router = mqttrouter.wrap(client);

router.subscribe('$RPC/time/request', function(topic, message){
  debug('received', topic, message);
});
```

*NOTE:* This currently just does simple subscriptions without wildcards, this is something I will work on next.
<commit_msg>Fixed up readme.<commit_after># mqtt-router [![Build Status](https://drone.io/github.com/wolfeidau/mqtt-router/status.png)](https://drone.io/github.com/wolfeidau/mqtt-router/latest)

This module a router for use with MQTT subscriptions.

[![NPM](https://nodei.co/npm/mqtt-router.png)](https://nodei.co/npm/mqtt-router/)
[![NPM](https://nodei.co/npm-dl/mqtt-router.png)](https://nodei.co/npm/mqtt-router/)

## Installation

```
npm install mqtt-router
```

# usage

```javascript
var mqtt = require('mqtt');
var mqttrouter = require('mqtt-router');
var debug = require('debug')('mqtt:consumer');

var client = mqtt.createClient();

var router = mqttrouter.wrap(client);

// this is only called ONCE for the matching topic
router.subscribe('$RPC/time/request', function(topic, message){
  debug('received', topic, message);
});

log('publish');
mqttclient.publish('$RPC/time/request', 'hello firstTopic!');

log('publish');
mqttclient.publish('$RPC/time/reply', 'hello secondTopic!');


```

*NOTE:* This currently just does simple subscriptions without wildcards, this is something I will work on next.

{'fraction_non_alphanumeric': 0.17906066536203522, 'fraction_numerical': 0.0, 'mean_word_length': 5.350931677018633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1101021', 'n_tokens_mistral': 729, 'n_tokens_neox': 699, 'n_words': 147}