Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gleicon
Created January 31, 2010 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gleicon/291126 to your computer and use it in GitHub Desktop.
Save gleicon/291126 to your computer and use it in GitHub Desktop.
var sys = require("sys");
var http = require("http");
var connections=[];
function update() {
if (connections.length) {
// do stuff
for (var c in connections) {
sys.puts(c);
connections[c].sendBody('oi');
}
}
setTimeout(update, 1000);
}
setTimeout(update, 1000);
http.createServer(function(req, res) {
if (req.url == '/clock') {
res.sendHeader(200, {'Content-type':'text/plain'});
connections.push(res);
} else {
res.sendHeader(404, {'Content-type':'text/plain'});
res.sendBody('not found');
}
//res.finish();
}).listen(8888);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment