Skip to content

Commit

Permalink
Added a basic example for bridging between two topics on MQTT.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Jan 2, 2013
1 parent c6e44c5 commit be582c1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/mqtt_topic_bridge.js
Original file line number Diff line number Diff line change
@@ -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.