Skip to content

Instantly share code, notes, and snippets.

@daneroo
Created November 22, 2010 06:46
Show Gist options
  • Select an option

  • Save daneroo/709618 to your computer and use it in GitHub Desktop.

Select an option

Save daneroo/709618 to your computer and use it in GitHub Desktop.
chat away
var clientNames=[];
for (var i=0;i<10000;i++){
clientNames.push("client-"+(1e7+i*5));
}
clientNames.forEach(function(cn) {
var channel = cn.substr(0,cn.length-1);
var total=0;
hub.fromClient(cn).subscribe(channel, function listenerFunction(message){
total++;
if (total%10==0){
print (cn+" <--: "+message.name+" ("+total+")");
}
});
});
var pubs={};
clientNames.forEach(function(cn) {
pubs[cn] = function(){
//print (cn+" -->");
var channel = cn.substr(0,cn.length-1);
hub.fromClient(cn).publish(channel, {name:"msg-from-"+cn});
setTimeout(pubs[cn],Math.random()*5000);
};
pubs[cn]();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment