Skip to content

Instantly share code, notes, and snippets.

@apeace
Created August 3, 2015 22:07
Show Gist options
  • Save apeace/e892dcbbc0d479241c50 to your computer and use it in GitHub Desktop.
Save apeace/e892dcbbc0d479241c50 to your computer and use it in GitHub Desktop.
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');
});
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