Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.interval = function(func, wait, times) {
- var interv = function(w, t) {
- return function() {
- if (typeof t === "undefined" || t-- > 0) {
- setTimeout(interv, w);
- try {
- func.call(null);
- } catch(e) {
- t = 0;
- throw e.toString();
- }
- } else {
- alert('stop');
- }
- };
- } (wait, times);
- setTimeout(interv, wait);
- }
- handler = new WebSocket(url);
- loop = 1;
- $.interval(function(){
- rs = handler.readyState;
- console.log("(" + loop++ + ") readyState: " + rs);
- }, 25, 10); //loop 10 times every 25 milliseconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement