Created
August 3, 2015 22:07
-
-
Save apeace/e892dcbbc0d479241c50 to your computer and use it in GitHub Desktop.
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
var client = require('socket.io-client')('http://10.0.2.2:9000/'); | |
client.on('connect', function () { | |
console.log('connect'); | |
}); | |
client.on('disconnect', function () { | |
console.log('disconnect'); | |
}); |
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
var io = require('socket.io')(); | |
var count = 0; | |
io.on('connection', function (socket) { | |
count++; | |
console.log('%d clients connected', count); | |
socket.once('disconnect', function () { | |
count--; | |
console.log('%d clients connected', count); | |
}); | |
}); | |
io.listen(9000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment