{"size": 593, "ext": "js", "max_stars_repo_path": "code_ie/mqtt_ws/index.js", "max_stars_repo_name": "mhellar/io", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "code_ie/mqtt_ws/index.js", "max_issues_repo_name": "mhellar/io", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code_ie/mqtt_ws/index.js", "max_forks_repo_name": "mhellar/io", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.72, "max_line_length": 51, "alphanum_fraction": 0.6188870152}
var mqtt    = require('mqtt');
var client  = mqtt.connect('mqtt://192.168.1.117');
var app = require('express')();

var server = app.listen(3000);
var io = require('socket.io')(server);

app.get('/', function(req, res) {
    res.sendFile(__dirname + '/index.html');
});

 
client.on('connect', function () {
  client.subscribe('/feeds/button');
  // client.publish('presence', 'Hello mqtt');
});
 
client.on('message', function (topic, message) {
  // message is Buffer 
  incoming = message.toString()
  console.log(incoming);
      io.sockets.emit('data', {
        val: incoming
    });
});