Created
February 9, 2014 11:13
-
-
Save arunoda/8897718 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 DDPClient = require('ddp'); | |
var totalClients = 0; | |
var postsList = 0; | |
var postsListUsers = 0; | |
var postsList | |
function createClient(closeTimeout) { | |
console.log('CREATING....', closeTimeout); | |
var client = new DDPClient({ | |
host: "107.170.25.58", | |
port: 80 | |
}); | |
client.connect(function(err) { | |
if(err) throw err; | |
console.log('connected - ', ++totalClients); | |
client.subscribe('postsList', [{"view":"preload"}], function() { | |
postsList++; | |
}); | |
client.subscribe('postsListUsers', [{"view":"preload"}], function() { | |
postsListUsers++; | |
}); | |
}); | |
client.on('socket-close', function(code, message) { | |
postsListUsers--; | |
postsList--; | |
totalClients--; | |
console.log('disonnected - ', totalClients, postsList, postsListUsers); | |
}); | |
setTimeout(function() { | |
client.close(); | |
}, closeTimeout); | |
return client; | |
} | |
setInterval(function() { | |
console.log('STATUS:', totalClients, postsList, postsListUsers); | |
}, 5000); | |
// createClient(50000); | |
var olderClient = 0; | |
setInterval(function() { | |
//20session/sec => 60 * 20 session total | |
for(var lc=0; lc<20; lc++) { | |
createClient(1000 * 60); | |
} | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment