Skip to content

Instantly share code, notes, and snippets.

@Fabryz
Created November 19, 2013 23:46
Show Gist options
  • Save Fabryz/7554681 to your computer and use it in GitHub Desktop.
Save Fabryz/7554681 to your computer and use it in GitHub Desktop.
var events = require('events');
module.exports = new events.EventEmitter();
...
socket.on('arduino', function(data) {
console.log('arduino data has arrived');
});
var bus = require('./bus');
...
app.get('/arduino', function(req, res) {
bus.emit('arduino');
res.send("OK");
});
var server = http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port "+ app.get('port') +" in "+ app.get('env') +" mode.");
});
...
bus.on('arduino', function() {
console.log("arduino");
io.sockets.emit('arduino');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment