Skip to content

Instantly share code, notes, and snippets.

@desireesantos
Last active August 29, 2015 14:04
Show Gist options
  • Save desireesantos/22c90bda6d19927a82a4 to your computer and use it in GitHub Desktop.
Save desireesantos/22c90bda6d19927a82a4 to your computer and use it in GitHub Desktop.
Módulo responsável por gerenciar socket
var ws = require('ws');
exports.create = function () {
machine = new Machine(name,status);
ws.callSocket(machine.status);
}
var io ;
module.exports = function (http) {
io = require('socket.io')(http);
console.log('Start connection')
getSocket(0);
}
exports.callSocket = function(status){
getSocket(status);
}
function getSocket (level) {
io.on('connection', function (client) {
console.log('Sending data ...')
client.emit('coffee:level', level);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment