Skip to content

Instantly share code, notes, and snippets.

@karenpeng
Last active March 20, 2019 18:39
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 karenpeng/120a881af2f6670657fff28022636be6 to your computer and use it in GitHub Desktop.
Save karenpeng/120a881af2f6670657fff28022636be6 to your computer and use it in GitHub Desktop.
// example below uses express.js
let counter = 0;
app.get('/longpolling', (req, res, next) => {
const delay = Math.random();
setTimeout(() => {
res.send({
random: delay,
sequence: counter
});
counter++;
}, delay * 30000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment