Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. $.interval = function(func, wait, times) {
  2. var interv = function(w, t) {
  3. return function() {
  4. if (typeof t === "undefined" || t-- > 0) {
  5. setTimeout(interv, w);
  6. try {
  7. func.call(null);
  8. } catch(e) {
  9. t = 0;
  10. throw e.toString();
  11. }
  12. } else {
  13. alert('stop');
  14. }
  15. };
  16. } (wait, times);
  17. setTimeout(interv, wait);
  18. }
  19.  
  20. handler = new WebSocket(url);
  21. loop = 1;
  22. $.interval(function(){
  23. rs = handler.readyState;
  24. console.log("(" + loop++ + ") readyState: " + rs);
  25. }, 25, 10); //loop 10 times every 25 milliseconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement