Refactor: Support not sending duplicate messages

Keep track of the md5 within a separate function.  Avoids duplication of code on the nchan scripts, and allows for the script to still exit if no listeners without adding in more code within each script to handle this.
This commit is contained in:
Squidly271
2025-08-10 18:13:10 -04:00
parent fa5c87cc75
commit 408331edf5
9 changed files with 43 additions and 28 deletions

View File

@@ -88,10 +88,7 @@ while (true) {
if ($running < 1) $echo = "<tr><td colspan='7' style='text-align:center;padding-top:12px'>"._('No VMs running')."</td></tr>";
$echo = json_encode($echo);
$md5_new = md5($echo,true);
if ($md5_new !== $md5_old) {
$md5_old = publish('vm_usage',$echo,true)!==false ? $md5_new : -1;
}
publish_md5('vm_usage',$echo,true);
sleep($timer);
}