Last active
August 29, 2015 14:19
-
-
Save vcanales/87cf8bc20a86d0ce355d to your computer and use it in GitHub Desktop.
This configuration leaves express running on ports 3000 and 3030.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This configuration leaves express running on ports 3000 and 3030. I need to avoid that. Help! | |
var server = app.listen(3030, function() { | |
debug('Express server listening on port '+ server.address().port); | |
}); | |
var io = require('socket.io')(server); | |
var connections = 0; | |
io.sockets.on('connection', function(socket) { | |
connections++; | |
console.log('client connected ('+connections+' total)'); | |
socket.emit('info', { clients: connections }); | |
socket.on('disconnect',function() { | |
connections--; | |
console.log('client disconnected ('+connections+' left)'); | |
io.sockets.emit('info', { clients: connections }); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment