Skip to content

Instantly share code, notes, and snippets.

@marcusandre
Created September 7, 2013 10:44
Show Gist options
  • Save marcusandre/6474570 to your computer and use it in GitHub Desktop.
Save marcusandre/6474570 to your computer and use it in GitHub Desktop.
ping
// `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)
};
@marcusandre
Copy link
Author

or just save a last activity timestamp on a real activity (e.g. topic created, comment posted, ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment