Permalink
Browse files

Added files to repo.

  • Loading branch information...
0 parents commit c299656038dd319474347fea6d84e90e21e37b2f @steveWang steveWang committed Jul 19, 2011
Showing with 433 additions and 0 deletions.
  1. +11 −0 README
  2. +31 −0 now_barebones.js
  3. +376 −0 nowclient.js
  4. +15 −0 package.json
11 README
@@ -0,0 +1,11 @@
+nowclient: A Node.js client for Now
+===================================
+
+Requires `websocket-client` (`npm install websocket-client`) and
+`socket.io-nodeclient` (`git clone
+git://github.com/ericz/socket.io-nodeclient.git`).
+
+`now_barebones.js` is a quick example of how to use nowclient.
+
+Usage: `node now_barebones.js http://myserver:port/`, where
+`http://myserver:port/` indicates where your Now server is running.
@@ -0,0 +1,31 @@
+var nowclient = require('./clusterclient.js');
+var now = nowclient.now;
+var socket = nowclient.socket;
+var interval;
+var total = 0, count = 0, sent = 0, startTime;
+setTimeout(function () {
+ var outbound = 0, lastCount = 0;
+ var a, b;
+ now.receiveMessage = function (message) {
+ if (count == 10000) {
+ console.log(total/count);
+ now.receiveMessage = function () {};
+ clearInterval(a);
+ clearInterval(b);
+ return;
+ }
+ ++count;
+ total += Date.now() - message;
+ };
+ now.start = function (interval) {
+ count = 0;
+ a = setInterval(function () {
+ outbound++;
+ now.distributeMessage(Date.now());
+ }, interval);
+ b = setInterval(function () {
+ console.log(outbound, -lastCount + (lastCount = count));
+ outbound = 0;
+ }, 1000);
+ };
+}, 1000);
Oops, something went wrong.

0 comments on commit c299656

Please sign in to comment.