Created
September 7, 2013 10:44
-
-
Save marcusandre/6474570 to your computer and use it in GitHub Desktop.
ping
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
// `ping` backend from client via websocket | |
// frontend code | |
// ping every 60 seconds or so | |
ping.send({ | |
"user": userid, | |
"time": new Date.now() | |
}); | |
// server code | |
ping.on('data', handlePing); | |
function handlePing(data) { | |
// save the ping time in user profile (e.g. last activity) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
or just save a last activity timestamp on a real activity (e.g. topic created, comment posted, ...)