Created
November 22, 2010 06:46
-
-
Save daneroo/709618 to your computer and use it in GitHub Desktop.
chat away
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 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