Prechádzať zdrojové kódy

Send client heartbeat as long as logged in

Vijayakrishnan 5 rokov pred
rodič
commit
f12ae13fbb
1 zmenil súbory, kde vykonal 8 pridanie a 19 odobranie
  1. 8 19
      resources/views/client-dashboard.blade.php

+ 8 - 19
resources/views/client-dashboard.blade.php

@@ -222,12 +222,6 @@
                         // turn client video off
                         $.post('/api/clientVideoVisit/turnClientVideoOff', {}, function(_data) {
                             console.log(_data);
-
-                            // stop heart beat
-                            if(self.heartbeatTimer) {
-                                window.clearInterval(self.heartbeatTimer);
-                                self.heartbeatTimer = false;
-                            }
                         });
 
                         // in case of accidental disconnection
@@ -262,12 +256,7 @@
                         $.post('/api/clientVideoVisit/turnClientVideoOn', {}, function(_data) {
                             console.log(_data);
 
-                            // start heart beat
-                            self.heartbeatTimer = window.setInterval(function() {
-                                $.post('/api/clientVideoVisit/registerClientVideoHeartbeat', {}, function(_data) {
-                                    console.log(_data);
-                                });
-                            }, 5000);
+
 
                         });
                     });
@@ -289,13 +278,6 @@
                         // turn client video off
                         $.post('/api/clientVideoVisit/turnClientVideoOff', {}, function(_data) {
                             console.log(_data);
-
-                            // stop heart beat
-                            if(self.heartbeatTimer) {
-                                window.clearInterval(self.heartbeatTimer);
-                                self.heartbeatTimer = false;
-                            }
-
                         });
                     });
 
@@ -471,6 +453,13 @@
                     return false;
                 });
 
+                // start heart beat
+                self.heartbeatTimer = window.setInterval(function() {
+                    $.post('/api/clientVideoVisit/registerClientVideoHeartbeat', {}, function(_data) {
+                        console.log(_data);
+                    });
+                }, 5000);
+
             }
         });
     </script>