I am building an interface between FreePBX 13 and a custom CRM. I must use 13 because HA is a critical requirement, so I have to live with PHP 5.3. When my AMI listener receives an AgentCalled event, it has to somehow send a message to the called agent’s browser to load a URL into a frame using the data from the AgentCalled event.
One problem with many of the solutions I have tried is that my client has a heartbeat process that runs every 5 seconds that confirms the extension is reachable and the browser has a current heartbeat timestamp. If either is false, the agent is automatically logged out of the queue. This is required so agents don’t get calls if their browser is hung or closed as they would not get call info in that case. A continues WHILE loop to listen for messages stops the heartbeat. Here is the heartbeat code:
When the page loads, <?php echo $exten; ?> is populated with the extension (this is index.php) and everything works great until the window.setInterval stops when a continuous loop listener is invoked in a child process to catch messages.
So, I have found another tutorial https://entwickler.de/webandphp/integrating-node-js-with-php-125830.html that looks promising. It is from 2013 which puts it in the PHP 5.3 world. I will give it a shot, but I’m sure I am re-inventing the wheel here because FreePBX sends messages to web pages from PHP all over the place and there MUST be some existing component I could re-use. Can anyone offer guidance?