Permalink
Browse files

Added a basic example for bridging between two topics on MQTT.

  • Loading branch information...
1 parent c6e44c5 commit be582c10c1200c7b8d42099f0ce23c0cd1de7d21 @mcollina committed Jan 2, 2013
Showing with 23 additions and 0 deletions.
  1. +23 −0 examples/mqtt_topic_bridge.js
View
23 examples/mqtt_topic_bridge.js
@@ -0,0 +1,23 @@
+
+var MQTTAscoltatore = require('../').MQTTAscoltatore;
+var ascoltatore = new MQTTAscoltatore({
+ mqtt: require("mqttjs"),
+ host: "127.0.0.1",
+ port: 1883
+});
+
+ascoltatore.on("ready", function() {
+
+ ascoltatore.subscribe("sink", function(topic, message) {
+ console.log(message);
+ });
+
+ ascoltatore.subscribe("a/*", function(topic, message) {
+ ascoltatore.publish("sink", topic + ": " + message);
+ });
+
+ ascoltatore.publish("a/g", "hello world");
+ ascoltatore.publish("a/f", "hello world");
+});
+
+

0 comments on commit be582c1

Please sign in to comment.