Skip to content

Instantly share code, notes, and snippets.

@thebergamo
Forked from anonymous/index.js
Created July 25, 2014 19:03
Show Gist options
  • Save thebergamo/9a9acdabf3bbbe1f1d8f to your computer and use it in GitHub Desktop.
Save thebergamo/9a9acdabf3bbbe1f1d8f to your computer and use it in GitHub Desktop.
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res) {
res.sendfile('index.html');
});
io.on('connection', function(socket) {
console.log('um usuario conectado');
socket.on('disconnect', function() {
console.log('usuario desconectado');
io.emit('usuario desconectado'); //AQUI OCORRE O ERRO
});
socket.on('chat message', function(data) {
console.log('message: ' + data.message);
io.emit('chat message', data.message);
});
});
http.listen(3000, function() {
console.log('Rodando na porta: 3000');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment