Skip to content

Instantly share code, notes, and snippets.

@jergason
Created August 26, 2011 16:44
Show Gist options
  • Save jergason/1173831 to your computer and use it in GitHub Desktop.
Save jergason/1173831 to your computer and use it in GitHub Desktop.
Chat server callback stuff
var storage = {
"messages": [],
"callbacks": []
};
function await_message(func) {
storage.callbacks.push(func);
}
//inside my Connect route
app.get("/whatever", function(req, res, next) {
if (!req.query.until) {
await_message(function(m) {
res.end(JSON.stringify(m));
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment