Skip to content

Instantly share code, notes, and snippets.

@masterfermin02
Last active March 27, 2021 17:33
Show Gist options
  • Save masterfermin02/8d87bd13c67a39cc093c711c2642b31e to your computer and use it in GitHub Desktop.
Save masterfermin02/8d87bd13c67a39cc093c711c2642b31e to your computer and use it in GitHub Desktop.
Vicidial Google Chrome and Javascript Throttling fix

Fix google chrome and Javascript Throttling.

Fix

You need to add this code to the agc/vicidial.php file:

1- Add this variable around line 4708

var source = null

2- Looks for setTimeout("all_refresh()", refresh_interval) around line 19708 and replace it by:

 if(typeof(EventSource) !== "undefined") {
    if (!source) {
      source = new EventSource("sse.php?refresh_interval=" + refresh_interval);
      source.onmessage = function(event) {
        // console.log('event', event);
        all_refresh();
      };
    }
  } else {
      setTimeout("all_refresh()", refresh_interval);
  }

3- Add the file sse.php to the dir agc/

<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
$time = date('r');
// If the connection closes, retry in 1 second
echo "retry: {$_GET['refresh_interval']}\n";
echo "data: The server time is: {$time}\n\n";
flush();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment