Skip to content

Instantly share code, notes, and snippets.

@WowSuchRicky
Created October 24, 2015 06:47
Show Gist options
  • Select an option

  • Save WowSuchRicky/eba19e3ab82736771ff7 to your computer and use it in GitHub Desktop.

Select an option

Save WowSuchRicky/eba19e3ab82736771ff7 to your computer and use it in GitHub Desktop.
var lastEmit = new Date().getTime();
socket.on("click", function (data) {
var newEmit = new Date().getTime();
console.log("Old emit: " + lastEmit + " , new emit: " + newEmit);
if (newEmit < (lastEmit + 50) && newEmit > 0) {
io.sockets.emit("error");
} else {
io.sockets.emit("click", data);
lastEmit = new Date().getTime();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment