Created
April 17, 2017 13:48
-
-
Save famasya/b64e6110f9beb94261816c1a709323ba to your computer and use it in GitHub Desktop.
Periodically checking token validity by web worker
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
self.addEventListener('message', function(e){ | |
setInterval(function(){ | |
self.postMessage("Checking token "+e.data); | |
// Do AUTH checking here... | |
}, 1000); | |
}, false); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Web Worker</title> | |
</head> | |
<body> | |
</body> | |
<script type="text/javascript"> | |
if(window.Worker){ | |
var worker = new Worker('task.js'); | |
var token = "j3l21hdsakh321kjhbdsaiuoi321dlasopinac"; | |
worker.addEventListener('message', function(e){ | |
// process returned data | |
console.log('He said : '+e.data); | |
}, false); | |
worker.postMessage(token); | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment