mqttest/iotsubcli.js

Thu, 04 Jun 2015 14:50:33 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 04 Jun 2015 14:50:33 +0200
changeset 0
e8ccd40d0ef6
permissions
-rw-r--r--

Genesis of lecture sources for Droidcon Berlin 2015 in Postbahnhof.

     1 // Simple subscribe client
     3 //var mqtt = require('mqtt'), locli = mqtt.connect('mqtt://test.mosquitto.org/');
     4 //var mqtt = require('mqtt'), locli = mqtt.connect('mqtt://192.168.42.250/');
     5 var mqtt = require('mqtt'), locli = mqtt.connect('mqtt://raspeinz.local/');
     7 locli.on('connect', function () {
     8   locli.subscribe('iotmsg');
     9 });
    11 locli.on('message', function(topic, message) {
    12   console.log(message.toString());
    13   //locli.end();
    14 });
    16 // disable automatic reconnect
    17 locli.options.reconnectPeriod = 0;

mercurial