├── .npm └── package │ ├── .gitignore │ ├── README │ └── npm-shrinkwrap.json ├── .versions ├── README.md ├── browserMqtt.js ├── client.js ├── mqtt-tests.js ├── package.js └── server.js /.npm/package/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.npm/package/README: -------------------------------------------------------------------------------- 1 | This directory and the files immediately inside it are automatically generated 2 | when you change this package's NPM dependencies. Commit the files in this 3 | directory (npm-shrinkwrap.json, .gitignore, and this README) to source control 4 | so that others run the same versions of sub-dependencies. 5 | 6 | You should NOT check in the node_modules directory that Meteor automatically 7 | creates; if you are using git, the .gitignore file tells git to ignore it. 8 | -------------------------------------------------------------------------------- /.npm/package/npm-shrinkwrap.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mqtt": { 4 | "version": "1.0.10", 5 | "dependencies": { 6 | "commist": { 7 | "version": "1.0.0", 8 | "dependencies": { 9 | "leven": { 10 | "version": "1.0.1" 11 | } 12 | } 13 | }, 14 | "concat-stream": { 15 | "version": "1.4.7", 16 | "dependencies": { 17 | "typedarray": { 18 | "version": "0.0.6" 19 | }, 20 | "readable-stream": { 21 | "version": "1.1.13", 22 | "dependencies": { 23 | "core-util-is": { 24 | "version": "1.0.1" 25 | }, 26 | "isarray": { 27 | "version": "0.0.1" 28 | }, 29 | "string_decoder": { 30 | "version": "0.10.31" 31 | } 32 | } 33 | } 34 | } 35 | }, 36 | "end-of-stream": { 37 | "version": "1.1.0", 38 | "dependencies": { 39 | "once": { 40 | "version": "1.3.1", 41 | "dependencies": { 42 | "wrappy": { 43 | "version": "1.0.1" 44 | } 45 | } 46 | } 47 | } 48 | }, 49 | "help-me": { 50 | "version": "0.1.0", 51 | "dependencies": { 52 | "pump": { 53 | "version": "1.0.0", 54 | "dependencies": { 55 | "once": { 56 | "version": "1.3.1", 57 | "dependencies": { 58 | "wrappy": { 59 | "version": "1.0.1" 60 | } 61 | } 62 | } 63 | } 64 | } 65 | } 66 | }, 67 | "inherits": { 68 | "version": "2.0.1" 69 | }, 70 | "minimist": { 71 | "version": "1.1.0" 72 | }, 73 | "mqtt-connection": { 74 | "version": "2.1.1", 75 | "dependencies": { 76 | "reduplexer": { 77 | "version": "1.1.0" 78 | }, 79 | "through2": { 80 | "version": "0.6.3" 81 | } 82 | } 83 | }, 84 | "mqtt-packet": { 85 | "version": "3.2.0", 86 | "dependencies": { 87 | "bl": { 88 | "version": "0.9.4" 89 | } 90 | } 91 | }, 92 | "readable-stream": { 93 | "version": "1.0.33", 94 | "dependencies": { 95 | "core-util-is": { 96 | "version": "1.0.1" 97 | }, 98 | "isarray": { 99 | "version": "0.0.1" 100 | }, 101 | "string_decoder": { 102 | "version": "0.10.31" 103 | } 104 | } 105 | }, 106 | "websocket-stream": { 107 | "version": "1.3.2", 108 | "dependencies": { 109 | "duplexify": { 110 | "version": "3.2.0", 111 | "dependencies": { 112 | "end-of-stream": { 113 | "version": "1.0.0", 114 | "dependencies": { 115 | "once": { 116 | "version": "1.3.1", 117 | "dependencies": { 118 | "wrappy": { 119 | "version": "1.0.1" 120 | } 121 | } 122 | } 123 | } 124 | } 125 | } 126 | }, 127 | "through2": { 128 | "version": "0.6.3" 129 | } 130 | } 131 | }, 132 | "ws": { 133 | "version": "0.6.5", 134 | "dependencies": { 135 | "nan": { 136 | "version": "1.4.3" 137 | }, 138 | "options": { 139 | "version": "0.0.6" 140 | }, 141 | "ultron": { 142 | "version": "1.0.1" 143 | } 144 | } 145 | }, 146 | "xtend": { 147 | "version": "4.0.0" 148 | } 149 | } 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /.versions: -------------------------------------------------------------------------------- 1 | babel-compiler@5.8.24_1 2 | babel-runtime@0.1.4 3 | base64@1.0.4 4 | binary-heap@1.0.4 5 | blaze@2.1.3 6 | blaze-tools@1.0.4 7 | boilerplate-generator@1.0.4 8 | callback-hook@1.0.4 9 | check@1.1.0 10 | ddp@1.2.2 11 | ddp-client@1.2.1 12 | ddp-common@1.2.2 13 | ddp-server@1.2.2 14 | deps@1.0.9 15 | diff-sequence@1.0.1 16 | ecmascript@0.1.6 17 | ecmascript-runtime@0.2.6 18 | ejson@1.0.7 19 | geojson-utils@1.0.4 20 | html-tools@1.0.5 21 | htmljs@1.0.5 22 | id-map@1.0.4 23 | jquery@1.11.4 24 | local-test:mkarliner:mqtt@0.2.0 25 | logging@1.0.8 26 | meteor@1.1.10 27 | minimongo@1.0.10 28 | mkarliner:mqtt@0.2.0 29 | mongo@1.1.3 30 | mongo-id@1.0.1 31 | npm-mongo@1.4.39_1 32 | observe-sequence@1.0.7 33 | ordered-dict@1.0.4 34 | promise@0.5.1 35 | random@1.0.5 36 | reactive-var@1.0.6 37 | retry@1.0.4 38 | routepolicy@1.0.6 39 | spacebars@1.0.7 40 | spacebars-compiler@1.0.7 41 | tinytest@1.0.6 42 | tracker@1.0.9 43 | ui@1.0.8 44 | underscore@1.0.4 45 | webapp@1.2.3 46 | webapp-hashing@1.0.5 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Meteor package for MQTT.js npm module. 3 | 4 | MQTT.js mqtt client package with both server and client API's working. 5 | 6 | Basic Usage: 7 | 8 | var mqtt = require('mqtt'); 9 | var client = mqtt.connect('mqtt://test.mosquitto.org'); 10 | 11 | client.subscribe('presence'); 12 | client.publish('presence', 'Hello mqtt'); 13 | 14 | client.on('message', function (topic, message) { 15 | // message is Buffer 16 | console.log(message.toString()); 17 | }); 18 | 19 | client.end(); 20 | 21 | See: http://www.modern-industry.com/admin/Article/17-using-mqtt-with-meteor for an article on 22 | how to use with Meteor. 23 | 24 | See: http://www.thingstud.io for a cloud service to create UI's for MQTT 25 | 26 | See: https://www.npmjs.com/package/mqtt for full API 27 | 28 | 29 | -------------------------------------------------------------------------------- /client.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /mqtt-tests.js: -------------------------------------------------------------------------------- 1 | // Write your tests here! 2 | // Here is an example. 3 | Tinytest.add('example', function (test) { 4 | test.equal(true, true); 5 | }); 6 | -------------------------------------------------------------------------------- /package.js: -------------------------------------------------------------------------------- 1 | Package.describe({ 2 | name: 'mkarliner:mqtt', 3 | version: '0.2.0', 4 | summary: 'Connect Meteor to MQTT message broker', 5 | git: 'http://www.github.com/mkarliner/meteor-mqtt', 6 | documentation: 'README.md' 7 | }); 8 | 9 | Npm.depends({ 10 | "mqtt": "1.0.10" 11 | 12 | }) 13 | 14 | Package.onUse(function(api) { 15 | api.export("mqtt", "server"); 16 | api.versionsFrom('1.0.3.1'); 17 | api.addFiles('server.js', ["server"]); 18 | api.addFiles(['browserMqtt.js'], "client"); 19 | }); 20 | 21 | Package.onTest(function(api) { 22 | api.use('tinytest'); 23 | api.use('mkarliner:mqtt'); 24 | api.addFiles('mqtt-tests.js'); 25 | }); 26 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | // Write your package code here! 2 | 3 | mqtt = Npm.require("mqtt"); 4 | //var moment = Npm.require("moment"); 5 | // var mqttClient = {}; 6 | // var clients = {}; 7 | // 8 | // MQTT = { 9 | // connect: function(url, options){ 10 | // console.log("just checking"); 11 | // mqttClient = mqtt.connect(url, options); 12 | // mqttClient.on("connect", publish); 13 | // return mqttClient; 14 | // } 15 | // } 16 | // 17 | // MQTT.messages = new Meteor.Collection(null); 18 | // 19 | // 20 | // 21 | // function publish(){ 22 | // console.log("Publishing"); 23 | // Meteor.publish('messages', function(filter) { 24 | // var self = this, 25 | // ready = false; 26 | // console.log("FILTER ", filter); 27 | // mqttClient.on("message", function(topic, body) { 28 | // console.log(topic + ": " + body); 29 | // // build the object to store 30 | // var msg = { 31 | // message: body.toString(), 32 | // topic: topic, 33 | // ts: new Date() 34 | // }; 35 | // // add the message to the collection (see below...) 36 | // console.log("Message received and understood: ", msg); 37 | // self.added("messages", new Date().toString(), msg); 38 | // MQTT.messages.insert(msg); 39 | // }); 40 | // self.ready(); 41 | // ready = true; 42 | // }); 43 | // } 44 | // 45 | // 46 | // 47 | // 48 | // 49 | // 50 | // 51 | // Meteor.methods({ 52 | // MQTTconnect: function(url, options) { 53 | // 54 | // }, 55 | // MQTTsubscribe: function(topic){ 56 | // console.log("Client Subscription", topic); 57 | // mqttClient.subscribe(topic); 58 | // 59 | // } 60 | // }); 61 | // 62 | // MQTT.connect = function(host) { 63 | // console.log("I've been called"); 64 | // } 65 | --------------------------------------------------------------------------------