Last active
March 20, 2019 18:39
-
-
Save karenpeng/120a881af2f6670657fff28022636be6 to your computer and use it in GitHub Desktop.
This file contains 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
// 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